Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup: Improve logging when deleting related sidecar files #2521

Closed
centralhardware opened this issue Jul 17, 2022 · 12 comments
Closed

Cleanup: Improve logging when deleting related sidecar files #2521

centralhardware opened this issue Jul 17, 2022 · 12 comments
Assignees
Labels
enhancement Refactoring, improvement or maintenance task tested Changes have been tested successfully ux Impacts User Experience

Comments

@centralhardware
Copy link


1. What is not working as documented?

cleanup Removes orphan index entries and thumbnail files - i think is meaning that original folder don't be affected.
but in log i see

delete: removing file <path to my original folder>. file extension is mov

2. How can we reproduce it?

run cleanup command.

3. What behavior do you expect?

no files from original folder will be changed.

4. What could be the cause of your problem?

maybe its's wrong logs. I didn't check I don't have a test instance

5. Can you provide us with example files for testing, error logs, or screenshots?

https://gist.github.com/centralhardware/bf3d264beb99c1abe8bc54c1d287a8a8

6. Which software versions do you use?

last docker version

7. On what kind of device is PhotoPrism installed?

does not matter

8. Do you use a Reverse Proxy, Firewall, VPN, or CDN?

does not matter

@centralhardware centralhardware added the bug Something isn't working label Jul 17, 2022
@gyto6
Copy link
Contributor

gyto6 commented Jul 17, 2022

Not a bug to me. I use to run this command, and it doesn't affect my own files. They simply remove their relatives variable in the database tables.

Didi you check if the file's gone and do you now if you deleted it manually yourself?

@centralhardware
Copy link
Author

I'm a little afraid to experiment with my files. it's be a little difficult to restore previous state.

@centralhardware
Copy link
Author

centralhardware commented Jul 17, 2022

so i try, and it actually delete file from original folder. this is definitely not what i expect from this command
PS: deleted file MVI_5508.THM

@gyto6
Copy link
Contributor

gyto6 commented Jul 17, 2022

Does "Deleted" is marked in the "General" Panel ?

image

@centralhardware
Copy link
Author

no

image

@lastzero
Copy link
Member

The log message means the related index entry was deleted, not the original file. You are welcome to suggest a better message, but it's very likely not a bug and as such can't be handled with the highest priority.

@centralhardware
Copy link
Author

The log message means the related index entry was deleted,

so why file actually removed?

@lastzero
Copy link
Member

That is what I said. We could change it into "delete: removing orphan index file... *

@lastzero
Copy link
Member

I got to the bottom of this and found out that cleanup CAN actually delete physical files, especially sidecar files like JPEGs that are automatically created for a RAW, as well as JSON and YAML sidecar files. This was introduced to save disk space and avoid problems as described in the following issue:

The logs are created before anything is actually deleted, so they are not proof that an original was really removed. Note that the cleanup command is intended to remove any remaining artifacts of missing originals, including index entries and sidecar files. So in practice, no original media files should have been deleted, unless the index contains wrong information, e.g. if you put the file there while the cleanup was already running.

Nevertheless, I have refactored large parts of the feature to make sure that no files are deleted in originals when delete is disabled or read-only mode is enabled. Note that some users also use the originals folder for the generated sidecar files. For them, we do not want to break the existing functionality.

@lastzero
Copy link
Member

Improved logs when you run photoprism cleanup:

...
DEBU[2022-07-21T18:13:30Z] cleanup: removed thumbnail d/2/d/[...]_500x500_center.jpg 
DEBU[2022-07-21T18:13:30Z] media: debug/drone-av1.webm not found        
INFO[2022-07-21T18:13:30Z] media: removed sidecar debug/drone-av1.webm.jpg 
INFO[2022-07-21T18:13:30Z] media: removed sidecar debug/drone-av1.yml   
DEBU[2022-07-21T18:13:30Z] media: debug/drone-av1.webm.jpg not found    
DEBU[2022-07-21T18:13:30Z] cleanup: removed debug/drone-av1 from index  
DEBU[2022-07-21T18:13:30Z] media: debug/earth.720p.vp9.webm not found   
INFO[2022-07-21T18:13:30Z] media: removed sidecar debug/earth.720p.vp9.webm.jpg 
INFO[2022-07-21T18:13:30Z] media: removed sidecar debug/earth.720p.vp9.yml 
DEBU[2022-07-21T18:13:30Z] media: debug/earth.720p.vp9.webm.jpg not found 
DEBU[2022-07-21T18:13:30Z] cleanup: removed debug/earth.720p.vp9 from index 
DEBU[2022-07-21T18:13:30Z] media: debug/DSC_7534.NEF not found          
INFO[2022-07-21T18:13:30Z] media: removed sidecar debug/DSC_7534.NEF.jpg 
INFO[2022-07-21T18:13:30Z] media: removed sidecar debug/DSC_7534.yml    
DEBU[2022-07-21T18:13:30Z] media: debug/DSC_7534.NEF.jpg not found      
DEBU[2022-07-21T18:13:30Z] cleanup: removed debug/DSC_7534 from index   
INFO[2022-07-21T18:13:30Z] purge: found no orphan files in index [1.514197ms] 
DEBU[2022-07-21T18:13:30Z] index: updating counts 
DEBU[2022-07-21T18:13:30Z] index: updating covers                       
INFO[2022-07-21T18:13:30Z] removed 3 index entries and 29 thumbnails in 664.565893ms 
...

@lastzero lastzero changed the title cleanup command remove file from original folder Cleanup: Improve logging when deleting related sidecar files Jul 21, 2022
lastzero added a commit that referenced this issue Jul 21, 2022
Signed-off-by: Michael Mayer <michael@photoprism.app>
@lastzero lastzero self-assigned this Jul 21, 2022
@lastzero lastzero added enhancement Refactoring, improvement or maintenance task please-test Ready for acceptance test ux Impacts User Experience and removed bug Something isn't working labels Jul 21, 2022
lastzero added a commit that referenced this issue Jul 22, 2022
Signed-off-by: Michael Mayer <michael@photoprism.app>
@lastzero
Copy link
Member

These improvements can also be tested with the new preview build that is available shortly! 👍

@centralhardware
Copy link
Author

centralhardware commented Jul 23, 2022

work grate, thanks

@lastzero lastzero added tested Changes have been tested successfully and removed please-test Ready for acceptance test labels Jul 23, 2022
@lastzero lastzero moved this to Released 🌈 in Roadmap 🚀✨ Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Refactoring, improvement or maintenance task tested Changes have been tested successfully ux Impacts User Experience
Projects
Status: Release 🌈
Development

No branches or pull requests

4 participants