Open isdnfan opened 2 years ago
this query collects damaged files from DB and JOIN them with their file_versions
SELECT f.fileid
,fv.fileid AS version_fileid
,f.fspath
,fv.fspath AS version_fspath
,versionpath
,f.size
,versionsize
,f.mtime
,f.filetime
,fv.change_time
,fv.original_mtime
FROM (SELECT STORAGE,fileid
,path
, TRIM(LEADING 'files/' FROM path) AS fspath
,size
,mtime
, FROM_UNIXTIME(mtime) AS filetime
FROM oc_filecache
WHERE path LIKE 'files/%' AND mtime=0
#AND fileid=308330
#LIMIT 10
) f
JOIN (SELECT fileid
, SUBSTRING_INDEX(TRIM(LEADING 'files_versions/' FROM path),'.v',1) AS fspath
,path as versionpath
,size AS versionsize
,mtime
,FROM_UNIXTIME(mtime) AS change_time
,SUBSTRING_INDEX(name,'.v',-1) AS original_mtime
,FROM_UNIXTIME(SUBSTRING_INDEX(name,'.v',-1)) AS original_time
FROM oc_filecache
WHERE path LIKE 'files_versions/%.v%') fv
ON f.fspath=fv.fspath
un/comment the lines
#AND fileid=308330
#LIMIT 10
for less results
starting from here: https://help.nextcloud.com/t/desktop-client-3-4-0-destroys-local-time-stamp-and-keeps-uploading-data-to-server/128512/54?u=wwe
I didn’t find time to build reliable recovery procedure from this information as I’m not an expert in mysql but it should work as following:
additional sugar:
I didn’t investigate further - NC devs might know from the top of the head - i think oc_filecache table is not separated by user so if collect the information from DB you don’t need to iterate over each user to identify and recover the files, it should work in one go…