Miscellaneous fixups

This commit is contained in:
Aaron Lindsay 2013-08-14 22:58:34 -04:00
parent f80639c815
commit ccb35fc7a6
2 changed files with 6 additions and 5 deletions

View File

@ -142,10 +142,10 @@ func ProcessLocalEvent(globals AsinkGlobals, event *asink.Event) {
//get the file's hash //get the file's hash
hash, err := HashFile(tmpfilename) hash, err := HashFile(tmpfilename)
event.Hash = hash
if err != nil { if err != nil {
panic(err) panic(err)
} }
event.Hash = hash
//If the file didn't actually change, squash this event //If the file didn't actually change, squash this event
if latestLocal != nil && event.Hash == latestLocal.Hash { if latestLocal != nil && event.Hash == latestLocal.Hash {
@ -231,16 +231,16 @@ func ProcessRemoteEvent(globals AsinkGlobals, event *asink.Event) {
panic(err) panic(err)
} }
//TODO copy hashed file to another tmp, then rename it to the actual file. //copy hashed file to another tmp, then rename it to the actual file.
tmpfilename, err = util.CopyToTmp(hashedFilename, globals.tmpDir) tmpfilename, err = util.CopyToTmp(hashedFilename, globals.tmpDir)
if err != nil { if err != nil {
panic(err) panic(err)
} }
err = os.Rename(tmpfilename, absolutePath) err = os.Rename(tmpfilename, absolutePath)
if err != nil { if err != nil {
err := os.Remove(tmpfilename) err2 := os.Remove(tmpfilename)
if err != nil { if err2 != nil {
panic(err) panic(err2)
} }
panic(err) panic(err)
} }

View File

@ -34,6 +34,7 @@ func StartWatching(watchDir string, fileUpdates chan *asink.Event) {
if fi, err := os.Stat(ev.Name); err == nil && fi.IsDir() { if fi, err := os.Stat(ev.Name); err == nil && fi.IsDir() {
if ev.IsCreate() { if ev.IsCreate() {
filepath.Walk(ev.Name, watchDirFn) filepath.Walk(ev.Name, watchDirFn)
//TODO do a scan of this directory so we ensure any file events we missed before starting to watch this directory are caught
} }
continue continue
} }