1
0
Fork 0

Still send event when files' permissions change

This commit is contained in:
Aaron Lindsay 2013-09-08 23:30:13 -04:00
parent 1b4104a928
commit 1254a7fb45
1 changed files with 22 additions and 19 deletions

View File

@ -182,30 +182,33 @@ func ProcessLocalEvent(globals AsinkGlobals, event *asink.Event) {
}
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 {
os.Remove(tmpfilename)
event.LocalStatus |= asink.DISCARDED
return
}
//If neither the file contents nor permissions changed, squash this event completely
if event.Permissions == latestLocal.Permissions {
event.LocalStatus |= asink.DISCARDED
return
}
} else {
//rename to local cache w/ filename=hash
cachedFilename := path.Join(globals.cacheDir, event.Hash)
err = os.Rename(tmpfilename, cachedFilename)
if err != nil {
err := os.Remove(tmpfilename)
if err != nil {
panic(err)
}
panic(err)
}
//rename to local cache w/ filename=hash
cachedFilename := path.Join(globals.cacheDir, event.Hash)
err = os.Rename(tmpfilename, cachedFilename)
if err != nil {
err := os.Remove(tmpfilename)
//upload file to remote storage
StatStartUpload()
err = globals.storage.Put(cachedFilename, event.Hash)
StatStopUpload()
if err != nil {
panic(err)
}
panic(err)
}
//upload file to remote storage
StatStartUpload()
err = globals.storage.Put(cachedFilename, event.Hash)
StatStopUpload()
if err != nil {
panic(err)
}
} else {
//if we're trying to delete a file that we thought was already deleted, there's no need to delete it again
@ -307,7 +310,7 @@ func ProcessRemoteEvent(globals AsinkGlobals, event *asink.Event) {
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)
if err != nil && !util.ErrorFileNotFound(err) {
panic(err)