Revert "Cache file descriptors" (fixes #1096)

This reverts commit 992ad97ad5.

Causes issues on Windows which uses file locking.
Meaning we cannot archive or modify the file while it's open.
This commit is contained in:
Audrius Butkevicius
2014-12-08 11:54:22 +00:00
parent 4d9aa10532
commit a9339d0627
14 changed files with 295 additions and 546 deletions

View File

@@ -41,8 +41,6 @@ import (
"github.com/syncthing/syncthing/internal/stats"
"github.com/syncthing/syncthing/internal/symlinks"
"github.com/syncthing/syncthing/internal/versioner"
"github.com/AudriusButkevicius/lrufdcache"
"github.com/syndtr/goleveldb/leveldb"
)
@@ -88,7 +86,6 @@ type Model struct {
db *leveldb.DB
finder *files.BlockFinder
progressEmitter *ProgressEmitter
cache *lrufdcache.FileCache
deviceName string
clientName string
@@ -130,7 +127,6 @@ func NewModel(cfg *config.ConfigWrapper, deviceName, clientName, clientVersion s
m := &Model{
cfg: cfg,
db: db,
cache: lrufdcache.NewCache(25),
deviceName: deviceName,
clientName: clientName,
clientVersion: clientVersion,
@@ -699,11 +695,12 @@ func (m *Model) Request(deviceID protocol.DeviceID, folder, name string, offset
}
reader = strings.NewReader(target)
} else {
reader, err = m.cache.Open(fn)
reader, err = os.Open(fn) // XXX: Inefficient, should cache fd?
if err != nil {
return nil, err
}
defer reader.(*lrufdcache.CachedFile).Close()
defer reader.(*os.File).Close()
}
buf := make([]byte, size)