Avoid locking the files for an extended amount of time. Sublime Text
authorEgon Elbre <egonelbre@gmail.com>
Sun, 15 Dec 2013 14:49:23 +0000 (16:49 +0200)
committerspf13 <steve.francia@gmail.com>
Sat, 28 Dec 2013 18:46:09 +0000 (13:46 -0500)
doesn't like this and shows an error when modifying a file in rapid
succession.

source/filesystem.go

index f44f003f08fd549f4a68ca932d389a0a48afee1e..cefe4a950fc15643798ac8cf7840428f2ce81fee 100644 (file)
@@ -1,8 +1,10 @@
 package source
 
 import (
+       "bytes"
        "errors"
        "io"
+       "io/ioutil"
        "os"
        "path"
        "path/filepath"
@@ -93,11 +95,11 @@ func (f *Filesystem) captureFiles() {
                        if ignoreDotFile(filePath) {
                                return nil
                        }
-                       file, err := os.Open(filePath)
+                       data, err := ioutil.ReadFile(filePath)
                        if err != nil {
                                return err
                        }
-                       f.add(filePath, file)
+                       f.add(filePath, bytes.NewBuffer(data))
                        return nil
                }
        }