Still send event when files' permissions change
This commit is contained in:
parent
1b4104a928
commit
1254a7fb45
@ -182,30 +182,33 @@ 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)
|
||||||
event.LocalStatus |= asink.DISCARDED
|
//If neither the file contents nor permissions changed, squash this event completely
|
||||||
return
|
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
|
//upload file to remote storage
|
||||||
cachedFilename := path.Join(globals.cacheDir, event.Hash)
|
StatStartUpload()
|
||||||
err = os.Rename(tmpfilename, cachedFilename)
|
err = globals.storage.Put(cachedFilename, event.Hash)
|
||||||
if err != nil {
|
StatStopUpload()
|
||||||
err := os.Remove(tmpfilename)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
//upload file to remote storage
|
|
||||||
StatStartUpload()
|
|
||||||
err = globals.storage.Put(cachedFilename, event.Hash)
|
|
||||||
StatStopUpload()
|
|
||||||
if err != nil {
|
|
||||||
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
|
||||||
@ -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