File modification time changes after last write

Recommended Posts

I am having a weird problem that I can't explain.


I use HandBrakeCLI to convert a file \\server\share\foo.mkv to \\server\share\foo.tmp

I rename \\server\share\foo.tmp to \\server\share\foo.mkv

I store the \\server\share\foo.mkv modification time for later use.

The \\server\share\foo.mkv attributes are read by MediaInfo, FFprobe, and MKVMerge.

I come back later, and the stored time no longer matches the file modified time.


No other apps are modifying the file, and I can't figure out why the modification time would change.

I am running from Win10 x64 to Unraid over SMB to a user share.

I ran ProcessMonitor on the Win10 machine, filtering by the file name, and after HanBrakeCLI exists, no modification are done from the Win10 system to the file.

The pattern is HandBrakeCLI open write close, My code open read attributes close, FFprobe/MediaInfo/MKVMerge open read close.

Wait, My code open read attributes close, timestamp changed from last read timestamp.


I wrote a little monitoring app that will compare the file modified time with the previous time every second.

The pattern is always the same, file modified time changes on HandBrakeCLI exit, then it changes two more times.



4/30/2020 10:31:25 PM : 4/30/2020 10:31:21 PM != 4/27/2020 7:40:43 PM
4/30/2020 10:31:45 PM : 4/30/2020 10:31:36 PM != 4/30/2020 10:31:21 PM
4/30/2020 10:31:48 PM : 4/30/2020 10:31:48 PM != 4/30/2020 10:31:36 PM



4/30/2020 10:54:02 PM : 4/30/2020 10:54:01 PM != 4/27/2020 7:40:43 PM
4/30/2020 10:54:12 PM : 4/30/2020 10:54:03 PM != 4/30/2020 10:54:01 PM
4/30/2020 10:54:17 PM : 4/30/2020 10:54:17 PM != 4/30/2020 10:54:03 PM



4/30/2020 11:16:13 PM : 4/30/2020 11:16:12 PM != 4/27/2020 7:40:43 PM
4/30/2020 11:16:24 PM : 4/30/2020 11:16:15 PM != 4/30/2020 11:16:12 PM
4/30/2020 11:16:26 PM : 4/30/2020 11:16:26 PM != 4/30/2020 11:16:15 PM


I am speculating that the file modification is happening on the Unraid side.

A wild guess; maybe the FUSE code buffers the write, and the last buffered write updates the modified time, and when Samba comes back later, the now modified time is read, instead of the time at SMB file close?


Any other ideas?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.