sortphotos icon indicating copy to clipboard operation
sortphotos copied to clipboard

sortphotos caught in a busy-loop upon encountering a 0-byte file

Open stellingsimon opened this issue 4 years ago • 4 comments

Thanks for this nifty piece of software, I sure appreciate it!

I found a minor bug that's easy to work around once you realize what the cause is:

Observed Behavior

When running sortphotos on a large file tree, I observe that it stops always at the same spot, not producing output for minutes while consuming 100% CPU. I tracked the issue down to it trying to process a 0-byte file.

Expected Behavior

It should probably just ignore that 0-byte file, or at least abort with a meaningful error.

Workaround

Since you most likely don't care for 0-byte files, just delete them before running sortphotos:

find <photo-dir> -size 0 -exec rm {} \;

stellingsimon avatar Feb 07 '21 11:02 stellingsimon

I've also found the issue, but stronger than described above. On my freenas system (I5, 64gbram, etc.); running sortphotos on any folder with even a single 0 byte file hard crashes the entire system (even just a single folder with only a single 0 byte file). The script just permanently hangs on a file and just fills up all ram / swap space until the entire system just stops responding to anything.

The workaround described above works like a charm.

This is my shell script moves them instead of removing them.

#!/bin/sh

echo "Moving 0 byte files due to bug in sortphotos..."
find ~/sync/ -size 0 -exec mv '{}' ~/photos/emptyfiles/ \;

echo "Executing photo backup..."
python ~/photos/sortphotos/src/sortphotos.py --recursive --sort %Y/%m ~/sync/ ~/photos/sorted/

echo "Done!"

P.s. Thanks so much for this project, it's a great piece of kit!

MitosisByProxy avatar Apr 30 '21 16:04 MitosisByProxy

Hi,

I have the same problem, but it is not related to 0 byte files. When I run the script on a lot of directories and files it gets stuck in the exif analysis phase with 100% CPU usage and fills up the RAM until being killed.

If I run the script on the subdirectory, where it got stuck, it runs fine without problems.

I have no idea how to work around this. Right now I run the script on every subdirectory, which is annoying.

Cheers, Phil

philsynek avatar May 27 '21 13:05 philsynek

I got it resolved. I installed exiftool on the system as described in here and now it works!

philsynek avatar May 27 '21 23:05 philsynek

I got it resolved. I installed exiftool on the system as described in here and now it works!

This worked for me as another solution. Not entirely sure why this works though, surely exiftool should work the same installed as it does not installed? Weird...

HattMarris1 avatar Sep 15 '21 20:09 HattMarris1