Still send event when files' permissions change
This commit is contained in:
parent
1b4104a928
commit
1254a7fb45
@ -182,13 +182,15 @@ func ProcessLocalEvent(globals AsinkGlobals, event *asink.Event) {
|
|||||||
}
|
}
|
||||||
event.Hash = hash
|
event.Hash = hash
|
||||||
|
|
||||||
//If the file didn't actually change, squash this event
|
//If the hash is the same, don't try to upload the event again
|
||||||
if latestLocal != nil && event.Hash == latestLocal.Hash {
|
if latestLocal != nil && event.Hash == latestLocal.Hash {
|
||||||
os.Remove(tmpfilename)
|
os.Remove(tmpfilename)
|
||||||
|
//If neither the file contents nor permissions changed, squash this event completely
|
||||||
|
if event.Permissions == latestLocal.Permissions {
|
||||||
event.LocalStatus |= asink.DISCARDED
|
event.LocalStatus |= asink.DISCARDED
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
//rename to local cache w/ filename=hash
|
//rename to local cache w/ filename=hash
|
||||||
cachedFilename := path.Join(globals.cacheDir, event.Hash)
|
cachedFilename := path.Join(globals.cacheDir, event.Hash)
|
||||||
err = os.Rename(tmpfilename, cachedFilename)
|
err = os.Rename(tmpfilename, cachedFilename)
|
||||||
@ -207,6 +209,7 @@ func ProcessLocalEvent(globals AsinkGlobals, event *asink.Event) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//if we're trying to delete a file that we thought was already deleted, there's no need to delete it again
|
//if we're trying to delete a file that we thought was already deleted, there's no need to delete it again
|
||||||
if latestLocal != nil && latestLocal.IsDelete() {
|
if latestLocal != nil && latestLocal.IsDelete() {
|
||||||
@ -307,7 +310,7 @@ func ProcessRemoteEvent(globals AsinkGlobals, event *asink.Event) {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if latestLocal == nil || event.Permissions != latestLocal.Permissions {
|
if latestLocal == nil || event.Hash != latestLocal.Hash || event.Permissions != latestLocal.Permissions {
|
||||||
err := os.Chmod(absolutePath, event.Permissions)
|
err := os.Chmod(absolutePath, event.Permissions)
|
||||||
if err != nil && !util.ErrorFileNotFound(err) {
|
if err != nil && !util.ErrorFileNotFound(err) {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user