How Can I Ignore Partial Files?

Continuing the discussion from [Feature Request] Recursive Folder Trigger:


I'm working on a macro to automatically move shows recorded with PlayOn to be viewable on Plex. I wanted to use a Folder trigger, but since it does not work recursively I'm leaning towards a Periodic trigger. How can I ignore partial files just in case the macro triggers while a show is recording?

P.S. I'm using "move" in the macro below for testing but would change to copy and delete once I take it live.

Thanks.


Process PlayOn Files.kmmacros (37.3 KB)

Hey Christian,

Unfortunately macOS does not currently have a viable means of testing for a file-busy condition.

Unless PlayOn uses a temp-file that is detectable while recording and only when finished recording changes it to a .mp4 (or whatever), that’s going to be hard to fully automate.

-Chris

Thanks @ccstone. I wonder if the modified date attribute changes as the file grows… If so maybe I could only operate on files that haven’t changed in X hours.

Hey Christian,

That’s worth investigating.

-Chris

Personally, I’d use the file size over the modified date if possible. Presumably the file size changes.

@ccstone turns out the modification date does change as a file grows.

@peternlewis the only problem is I'd have to keep track of the file size and see when it stops changing. Using modification date, I don't have to keep track of anything other than the time the macro starts, can check that the file hasn't changed in the last, say 3600 seconds, and assume the download is finished.

Both of these methods have the same drawback: if I lose network connection while PlayOn is recording, eventually my macro will move an unfinished file into Plex. I'm gong to ignore that until it becomes a real problem.


Here's my proof of concept, compressing a desktop folder (imp) full of images as a stand in for my recording-in-progress:


And the output from my test log:

Trigger value:		~/Desktop/imp.zip
dmod:				1520703874	seconds ago:	1
Trigger value:		~/Desktop/imp.zip
dmod:				1520703875	seconds ago:	2
Trigger value:		~/Desktop/imp.zip
dmod:				1520703876	seconds ago:	3
Trigger value:		~/Desktop/imp.zip
dmod:				1520703877	seconds ago:	4
Trigger value:		~/Desktop/imp.zip
dmod:				1520703878	seconds ago:	5
Trigger value:		~/Desktop/imp.zip
dmod:				1520703879	seconds ago:	6
Trigger value:		~/Desktop/imp.zip
dmod:				1520703880	seconds ago:	7
Trigger value:		~/Desktop/imp.zip
dmod:				1520703881	seconds ago:	8
Trigger value:		~/Desktop/imp.zip
dmod:				1520703882	seconds ago:	9
Trigger value:		~/Desktop/imp.zip
dmod:				1520703883	seconds ago:	10