Am currently working on a small side project app that uses a file watcher to monitor specified folders for changes. One of the more common uses of the app would be a network share, such as a samba share. An example of one of these uses would be:
- One Windows client
- One MacOS client
- One Linux client
- One Ubuntu server running Samba service
When the Windows client adds a file to the share, only the MacOS client and Linux client are notified. However, the file watchers on each client (including the Windows client) will detect the new file. To be able to prevent the Windows client (the "creator" of the file) from getting the notification, I would need the app to be able to know who made the file.
// some funky pseudocode
func onFileCreated(e) {
if (e.File.Creator == GetHostName())
return;
SendToastNotification(e.File);
}
Currently, each client is signed into the same Samba user, and the Owner attribute displays the Samba user (as it should). I don't really understand the inner workings of Samba, but here are a few approaches I am thinking of:
- Each client has its own user on the Samba server (would be tedious to add more clients in the future)
- Each client is responsible for knowing if they have just written a file to the Samba share (would require high-level privileges to access file handlers)
- When a file is uploaded to the share, somehow the Samba server is able to add an arbitrary custom file attribute denoting the host name of whichever client made the file (best case scenario if possible)
Perhaps there are better options available. Many thanks in advance.