Closed tymmej closed 11 months ago
That code is necessary to add files from package to list with "known" files to prevent deletion when remove_obsolete is set to true.
process_package
nor download_files
does not do it. process_file
add to list only "base" name (name of package, not its content).
That's interesting. For packages, only package directory path should be enough to retain in the files list. remove_obsolete should have removed the local package directory and its contents. But apparently, it isn't removing it.
Looking into it....
Removing files are naive: https://github.com/mandarons/icloud-drive-docker/blob/ac2a960d29790504c63f0391a4bc622fade083cb/src/sync_drive.py#L235
rglob
finds all files, but on the list of wanted files there's only package directory path
. And only package directory path
is left after running remove_obsolete ()
.
Another solution is to change condition in https://github.com/mandarons/icloud-drive-docker/blob/ac2a960d29790504c63f0391a4bc622fade083cb/src/sync_drive.py#L237 to check if there's any part of path on list of wanted files.
https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.is_relative_to looks like what can be used but:
a) is deprecated
b) complexity might be a problem because it should be called for all entries in files
for each found file.
Describe the bug https://github.com/mandarons/icloud-drive-docker/commit/f85aa35f6573d2aa2a9ab9df480489ec403699e7 seems to break syncing packages.
To Reproduce Try to sync package with
remove_obsolete: true
Expected behavior Packages sync successfully, observed behavior: empty folder.
Logs
On filesystem is empty folder
/app/icloud/drive/Documents/PhotoStatistica.photostats
.Configuration
remove_obsolete: true
for drive.