Jump to content

Recommended Posts

Posted

Hello All,

 

There doesn't seem to be a widly-available tool to sync a whole Windows file server, consisting of individual user areas and a bunch of shared folders, to a Google domain account, so I'm writing one. So far, I have a Windows-based Python script managing to send files to Google Drive on behalf of a specific user, so now I need to expand that into a proper file-sync utility that updates files on either side whenever files are updated. Google provide an API for doing that - just register a URI to be notified of a file's ID whenever any file in a folder changes. Windows, however, only seems to provide an API call that notifies you that a file has changed - you still have to recurse down the directory tree to figure out which file has changed.

 

Have I got that right? Is the only available Windows file update notification the win32file.FindFirstChangeNotification call, or is there a better option?

 

I see there are a number of utilities available that will run a given application on file update, I imagine I could construct a solution around one of those. This implies a somewhat clunky install process, where you have to go and get two utilities and configure them for it all to work, but the other solution I can think of is to turn on file auditing and have something watch the auditing logs for updates. That strikes me as pretty much just as clunky, though - surely Windows must have a more efficient method available somewhere?

Posted
Is the only available Windows file update notification the win32file.FindFirstChangeNotification call, or is there a better option?

 

Ah ha - I've created an NTFS Change Journal log, and am attempting to read events via Python. I have example code for a QUERY_USN_JOURNAL call (win32file.DeviceIoControl(volh, winioctlcon.FSCTL_QUERY_USN_JOURNAL, None, len)), which tells me when there's a file that's been changed, but actually reading the relevant records is proving a bit trickier. Anyone any experience with this?

Posted
Okay, so it looks like Windows will give me the USN of a given file, plus the USN of its parent folder, but it won't tell me the USN / name of that parent's parent folder by USN, I have to keep a cache of folder / USN names in memory. Is that right, is there no way to simply get a full path string from a given USN?
  • 2 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...