Exit before attempting to use nil variables on scanning nonexistent folder
This commit is contained in:
parent
2fa45436c2
commit
22f39be197
|
@ -1080,25 +1080,25 @@ func (m *Model) ScanFolderSub(folder, sub string) error {
|
||||||
|
|
||||||
m.fmut.Lock()
|
m.fmut.Lock()
|
||||||
fs, ok := m.folderFiles[folder]
|
fs, ok := m.folderFiles[folder]
|
||||||
dir := m.folderCfgs[folder].Path
|
folderCfg := m.folderCfgs[folder]
|
||||||
|
|
||||||
ignores := m.folderIgnores[folder]
|
ignores := m.folderIgnores[folder]
|
||||||
_ = ignores.Load(filepath.Join(dir, ".stignore")) // Ignore error, there might not be an .stignore
|
m.fmut.Unlock()
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
return errors.New("no such folder")
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = ignores.Load(filepath.Join(folderCfg.Path, ".stignore")) // Ignore error, there might not be an .stignore
|
||||||
|
|
||||||
w := &scanner.Walker{
|
w := &scanner.Walker{
|
||||||
Dir: dir,
|
Dir: folderCfg.Path,
|
||||||
Sub: sub,
|
Sub: sub,
|
||||||
Matcher: ignores,
|
Matcher: ignores,
|
||||||
BlockSize: protocol.BlockSize,
|
BlockSize: protocol.BlockSize,
|
||||||
TempNamer: defTempNamer,
|
TempNamer: defTempNamer,
|
||||||
TempLifetime: time.Duration(m.cfg.Options().KeepTemporariesH) * time.Hour,
|
TempLifetime: time.Duration(m.cfg.Options().KeepTemporariesH) * time.Hour,
|
||||||
CurrentFiler: cFiler{m, folder},
|
CurrentFiler: cFiler{m, folder},
|
||||||
IgnorePerms: m.folderCfgs[folder].IgnorePerms,
|
IgnorePerms: folderCfg.IgnorePerms,
|
||||||
}
|
|
||||||
m.fmut.Unlock()
|
|
||||||
|
|
||||||
if !ok {
|
|
||||||
return errors.New("no such folder")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m.setState(folder, FolderScanning)
|
m.setState(folder, FolderScanning)
|
||||||
|
@ -1169,7 +1169,7 @@ func (m *Model) ScanFolderSub(folder, sub string) error {
|
||||||
"size": f.Size(),
|
"size": f.Size(),
|
||||||
})
|
})
|
||||||
batch = append(batch, nf)
|
batch = append(batch, nf)
|
||||||
} else if _, err := os.Lstat(filepath.Join(dir, f.Name)); err != nil && os.IsNotExist(err) {
|
} else if _, err := os.Lstat(filepath.Join(folderCfg.Path, f.Name)); err != nil && os.IsNotExist(err) {
|
||||||
// File has been deleted
|
// File has been deleted
|
||||||
nf := protocol.FileInfo{
|
nf := protocol.FileInfo{
|
||||||
Name: f.Name,
|
Name: f.Name,
|
||||||
|
|
Loading…
Reference in New Issue