Finish unfinished ProcessRemoteEvent functionality
This commit is contained in:
parent
d5c199c021
commit
fae1ed38d5
@ -168,7 +168,9 @@ func ProcessRemoteEvent(globals AsinkGlobals, event *asink.Event) {
|
||||
}
|
||||
|
||||
//Download event
|
||||
if event.IsUpdate() && (latestLocal == nil || event.Hash != latestLocal.Hash) {
|
||||
if event.IsUpdate() {
|
||||
if latestLocal == nil || event.Hash != latestLocal.Hash {
|
||||
|
||||
outfile, err := ioutil.TempFile(globals.tmpDir, "asink")
|
||||
if err != nil {
|
||||
panic(err) //TODO handle sensibly
|
||||
@ -181,7 +183,8 @@ func ProcessRemoteEvent(globals AsinkGlobals, event *asink.Event) {
|
||||
}
|
||||
|
||||
//rename to local hashed filename
|
||||
err = os.Rename(tmpfilename, path.Join(globals.cacheDir, event.Hash))
|
||||
hashedFilename := path.Join(globals.cacheDir, event.Hash)
|
||||
err = os.Rename(tmpfilename, hashedFilename)
|
||||
if err != nil {
|
||||
err := os.Remove(tmpfilename)
|
||||
if err != nil {
|
||||
@ -189,6 +192,21 @@ func ProcessRemoteEvent(globals AsinkGlobals, event *asink.Event) {
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
|
||||
//TODO copy hashed file to another tmp, then rename it to the actual file.
|
||||
tmpfilename, err = util.CopyToTmp(hashedFilename, globals.tmpDir)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = os.Rename(tmpfilename, event.Path)
|
||||
if err != nil {
|
||||
err := os.Remove(tmpfilename)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//intentionally ignore errors in case this file has been deleted out from under us
|
||||
os.Remove(event.Path)
|
||||
|
Loading…
Reference in New Issue
Block a user