Add file permission detection/restoring
This commit is contained in:
@ -113,6 +113,12 @@ func ProcessLocalEvent(globals AsinkGlobals, event *asink.Event) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fileinfo, err := os.Stat(event.Path)
|
||||
if err != nil && !util.ErrorFileNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
event.Permissions = fileinfo.Mode()
|
||||
|
||||
//get the file's hash
|
||||
hash, err := HashFile(tmpfilename)
|
||||
event.Hash = hash
|
||||
@ -207,6 +213,12 @@ func ProcessRemoteEvent(globals AsinkGlobals, event *asink.Event) {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
if latestLocal == nil || event.Permissions != latestLocal.Permissions {
|
||||
err := os.Chmod(event.Path, event.Permissions)
|
||||
if err != nil && !util.ErrorFileNotFound(err) {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//intentionally ignore errors in case this file has been deleted out from under us
|
||||
os.Remove(event.Path)
|
||||
|
Reference in New Issue
Block a user