lib/model: Always release the lock (#5126)

This commit is contained in:
Simon Frei 2018-08-15 16:33:03 +02:00 committed by Jakob Borg
parent ee42c46bd3
commit 7c0798b622

View File

@ -1307,8 +1307,6 @@ func (m *Model) Request(deviceID protocol.DeviceID, folder, name string, offset
return protocol.ErrInvalid
}
m.fmut.RLock()
if cfg, ok := m.cfg.Folder(folder); !ok || !cfg.SharedWith(deviceID) {
l.Warnf("Request from %s for file %s in unshared folder %q", deviceID, name, folder)
return protocol.ErrNoSuchFile
@ -1317,10 +1315,16 @@ func (m *Model) Request(deviceID protocol.DeviceID, folder, name string, offset
return protocol.ErrInvalid
}
folderCfg := m.folderCfgs[folder]
m.fmut.RLock()
folderCfg, ok := m.folderCfgs[folder]
folderIgnores := m.folderIgnores[folder]
m.fmut.RUnlock()
if !ok {
// The folder might be already unpaused in the config, but not yet
// in the model.
l.Debugf("Request from %s for file %s in unstarted folder %q", deviceID, name, folder)
return protocol.ErrInvalid
}
// Make sure the path is valid and in canonical form
var err error