LoWang Posted August 11, 2015 Share Posted August 11, 2015 (edited) Hello, I am about to create my own file sync utility but I wonder how to make its basic functionality - detect deleted files. How do google drive, dropbox and such things do it? I guess they have their own internal databases independent on file system right? One could say - just use robocopy with -mir parameter. But the problem of robocopy is, that is works one way only. You have to specify which folder is source and which is target. It considers source folder as a last state and mirrors the target folder according to source. But I want it to work both ways. That means that if I have two folders with photos and let's say I delete one photo in one folder and edit the same photo in another folder, I want my utility to recognize what change is most recent and sync according to that. For it I would like not only to know that the file is missing in one of the folder but also WHEN was it deleted. Because if it was deleted later then the modification date of the photo in first folder then I want the photo to be deleted from both. Anybody knows how it is usually done and if there is some best practice to handle this? Is it possible to read folder and find deleted file entries with date of deletion? I am not sure if this information is recorded in the folder at all...Maybe maintaining file list and comparing it with actual folder is the only options right? I guess WMI event handlers are also usually used to monitor folder changes, so point me to some tutorials if possible. Thank you. Edited August 11, 2015 by LoWang Link to comment Share on other sites More sharing options...
JohnOne Posted August 11, 2015 Share Posted August 11, 2015 One way I can see this working is to run a service or process that polls the folders contents periodically and logs the changes to it.Another might be to use this File System Monitor UDF. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
LoWang Posted August 11, 2015 Author Share Posted August 11, 2015 http://security.stackexchange.com/questions/61166/how-to-know-when-a-file-was-deleted-in-a-ntfs-filesystemhow about that? Do you think some common file sync/cloud software use NTFS journaling? Link to comment Share on other sites More sharing options...
rjframe Posted August 12, 2015 Share Posted August 12, 2015 http://security.stackexchange.com/questions/61166/how-to-know-when-a-file-was-deleted-in-a-ntfs-filesystemhow about that? Do you think some common file sync/cloud software use NTFS journaling?The easy way is to periodically check for changes as JohnOne says.You should realize that what that post talks about is the USN change journal - not NTFS journaling.If you really want to do it the hard way, you'll want to start with MSDN (https://msdn.microsoft.com/en-us/library/windows/desktop/aa363798(v=vs.85).aspx) and play with the API. Link to comment Share on other sites More sharing options...
LoWang Posted August 12, 2015 Author Share Posted August 12, 2015 rjframe what do you mean? I talk mainly about the first answer to that post. It contains some links and talks about ntfs journaling. Please be more clear with all those abbreviations and tell me what is USN BTW msdn link is broken :-\ Link to comment Share on other sites More sharing options...
JohnOne Posted August 12, 2015 Share Posted August 12, 2015 Remove ")" from link. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
rjframe Posted August 12, 2015 Share Posted August 12, 2015 @LoWangThe NTFS journal (or log, or transaction journal) records changes to the volume; it's used to ensure data reliability and consistency, so you don't want to mess with it. I have never studied the NTFS format, so I cannot be more specific than that.The USN Journal (update sequence number) records changes to directories, files, and streams, and can be monitored by applications via the API, documented at the link above. Link to comment Share on other sites More sharing options...
Caiaphas Posted August 14, 2015 Share Posted August 14, 2015 (edited) This is how I have figured out what you are trying to do and it works very well for me.#include <FileConstants.au3>Send("#m") ;~ this will minimize all open windows$title = "Xternal Backup By Henry "$Begtext = "Your Backup is about to commence" _ & @LF & "Please save and close any open programs." _ & @LF & "This program will start in 120 seconds."$Fintext = "Your Backup has completed successfully ! "$SourcePath = "<this would be the Source path where to copy your stuff to>"$TargetPath = "<this would be the Target path where to copy your stuff to>";~ I also like to use#NoTrayIcon ;~ hides the trayiconBreak(0) ;~ disables users ability to ctrl+break;~ whats missing is a couple of these copy and paste it and add any apps that might be open like word or outlook;~ Closes open programsLocal $MFF = ProcessExists("firefox.exe")If $MFF Then ProcessClose($MFF)Sleep(300)$sm = MsgBox(65 + 262144, $title, $Begtext, 120)If $sm = 2 Then ExitIf $sm = 1 Then $rc = RunWait("robocopy.exe" & " " & $SourcePath & " " & $TargetPath & "/e /eta /LOG+:e:\backup.log /tee")Else $rc = RunWait("robocopy.exe" & " " & $SourcePath & " " & $TargetPath & "/e /eta /LOG+:e:\backup.log /tee") MsgBox(262144, $title, $Fintext, 60) ExitEndIfBreak(1) ;~ turns off breakMsgBox(64, $title, $Fintext, 60) shared backup.au3 Edited August 14, 2015 by Caiaphas pasted code Link to comment Share on other sites More sharing options...
LoWang Posted August 14, 2015 Author Share Posted August 14, 2015 Thanks, but I am really not sure if you understood what I was asking at all Link to comment Share on other sites More sharing options...
Danyfirex Posted August 14, 2015 Share Posted August 14, 2015 maybe you're looking for something like this.Saludos LoWang 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
JohnOne Posted August 14, 2015 Share Posted August 14, 2015 Are you only interested in the link you gave yourself, or have you trued the file system monitor udf I linked to, which does exactly what you want? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
LoWang Posted August 16, 2015 Author Share Posted August 16, 2015 Actually I am not really interested in some monitoring app which would have to be running. Imagine that google drive also may not be running but once you run it it somehow detects changes and syncs. So I guess this UDF will not work for the type of utility which would not have to be running continuously am I right? But I mayt test that anyway. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now