Client Desktop mac change date to 01/01/1970 after download

Hi everybody,

i have an issue with last Desktop client mac 3.3.6, on mac OS 12.1. When synchroninzing each files, the date is changed to 01/01/1970 , so after the download, the client upload files again !

do you have an idea for me ?

i only have the problem on a signle mac.

Best Regard,
Julien

most likely you hit this problem

it doesn’t match your client version but the problem is exactly the same… maybe the client was updated somehow (or you have another client which run the problematic version

ok thanks for the info

We have a fix for the modification date issue . The script that next cloud provided doesn’t work on snap.

Create Bash Script .

Sudo nano dates.sh
Chmod 755 dates.sh
./dates.sh

files=$(find . type f -newermt "1969-01-01" ! -newermt "1971-01-01")

IFS=$'\n'

for f in $files
do
touch -m $files
done

Lastly run this command which can take some time.

sudo nextcloud.occ files:scan --all -vvv

4 Likes

How do I specify which folder to scan with this script. As in my ncdata directory.

There is typo - It has to be be “-type”

files=$(find . -type f -newermt "1969-01-01" ! -newermt "1971-01-01")

I do apolagise :slight_smile: thanks for pointing out.

I had even older files that caused sync errors, so i changed it to touch all files older than 1971:

files=$(find . -type f ! -newermt "1971-01-01")

IFS=$'\n'

for f in $files
do
touch -m $files
done

These posted scripts don’t really make sense because they are looping through $files and assigning each row to ‘f’, but then touching the entire array every time.

Also, I don’t like setting the modification time to now for every file. I’d rather set it to creation time because many files like images aren’t modified after written to the disk.

Thus, I’m using this script:

#!/bin/sh

IFS=$'\n'

FILES=$( find . -type f ! -newermt "1971-01-01" )

for FILE in $FILES; do

  NEWTIME=$( stat -c %z "$FILE" )
  echo "Setting '$FILE' to '$NEWTIME'"
  touch -m --date="$NEWTIME" "$FILE"

done
2 Likes

If you’re using bash 4.4+ try this one, as previously posted scripts seem not to work with some unicode characters and filepaths with spaces in them.

#!/usr/bin/env bash

mapfile -d '' eFILES < <( find . -type f ! -newermt "1971-01-01" -print0)

length=${#eFILES[@]}

for (( j=0; j<${length}; j++ ));
do
  FILE=${eFILES[$j]}
  NEWTIME=$( stat -c %z "${FILE}" )
  echo "Setting ${FILE} to ${NEWTIME}"
  touch -m --date="${NEWTIME}" "${FILE}"

done
1 Like

I get:

touch: invalid option -- 'Y'
Try 'touch --help' for more information.

I’m not familiar with the touch command, how can we print what’s going on?
Thanks!

I modified the script:
But strangely, I identified 12238 files with wrong modified dates.
However, only 123 files were touched and modified.

Here’s my modified script:

#!/usr/bin/env bash
read -p "filespath:" filespath

mapfile -d '' eFILES < <( find $filespath -type f ! -newermt "1971-01-01" -print0)

length=${#eFILES[@]}

for (( j=0; j<${length}; j++ ));
do
  FILE=${eFILES[$j]}
  NEWTIME=$( stat -c %z "${FILE}" )
  echo "Setting ${FILE} to ${NEWTIME}"
  touch -m --date="${NEWTIME}" "${FILE}"

done