lib: Folder marker is now a folder
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4341 LGTM: calmh
This commit is contained in:
committed by
Jakob Borg
parent
19e52a10df
commit
ab132ff6fe
@@ -336,7 +336,7 @@ func (m *Model) RemoveFolder(folder string) {
|
||||
// Delete syncthing specific files
|
||||
folderCfg := m.folderCfgs[folder]
|
||||
fs := folderCfg.Filesystem()
|
||||
fs.Remove(".stfolder")
|
||||
fs.RemoveAll(".stfolder")
|
||||
|
||||
m.tearDownFolderLocked(folder)
|
||||
// Remove it from the database
|
||||
@@ -1156,7 +1156,7 @@ func (m *Model) Request(deviceID protocol.DeviceID, folder, name string, offset
|
||||
// acceptable relative to "folderPath" and in canonical form, so we can
|
||||
// trust it.
|
||||
|
||||
if ignore.IsInternal(name) {
|
||||
if fs.IsInternal(name) {
|
||||
l.Debugf("%v REQ(in) for internal file: %s: %q / %q o=%d s=%d", m, deviceID, folder, name, offset, len(buf))
|
||||
return protocol.ErrNoSuchFile
|
||||
}
|
||||
@@ -1174,7 +1174,7 @@ func (m *Model) Request(deviceID protocol.DeviceID, folder, name string, offset
|
||||
// Only check temp files if the flag is set, and if we are set to advertise
|
||||
// the temp indexes.
|
||||
if fromTemporary && !folderCfg.DisableTempIndexes {
|
||||
tempFn := ignore.TempName(name)
|
||||
tempFn := fs.TempName(name)
|
||||
|
||||
if info, err := folderFs.Lstat(tempFn); err != nil || !info.IsRegular() {
|
||||
// Reject reads for anything that doesn't exist or is something
|
||||
@@ -2552,7 +2552,7 @@ func unifySubs(dirs []string, exists func(dir string) bool) []string {
|
||||
func trimUntilParentKnown(dirs []string, exists func(dir string) bool) []string {
|
||||
var subs []string
|
||||
for _, sub := range dirs {
|
||||
for sub != "" && !ignore.IsInternal(sub) {
|
||||
for sub != "" && !fs.IsInternal(sub) {
|
||||
sub = filepath.Clean(sub)
|
||||
parent := filepath.Dir(sub)
|
||||
if parent == "." || exists(parent) {
|
||||
|
||||
@@ -1026,7 +1026,8 @@ func changeIgnores(t *testing.T, m *Model, expected []string) {
|
||||
|
||||
func TestIgnores(t *testing.T) {
|
||||
// Assure a clean start state
|
||||
ioutil.WriteFile("testdata/.stfolder", nil, 0644)
|
||||
os.RemoveAll("testdata/.stfolder")
|
||||
os.MkdirAll("testdata/.stfolder", 0644)
|
||||
ioutil.WriteFile("testdata/.stignore", []byte(".*\nquux\n"), 0644)
|
||||
|
||||
db := db.OpenMemory()
|
||||
|
||||
@@ -760,7 +760,7 @@ func (f *sendReceiveFolder) deleteDir(file protocol.FileInfo, matcher *ignore.Ma
|
||||
files, _ := f.fs.DirNames(file.Name)
|
||||
for _, dirFile := range files {
|
||||
fullDirFile := filepath.Join(file.Name, dirFile)
|
||||
if ignore.IsTemporary(dirFile) || (matcher != nil && matcher.Match(fullDirFile).IsDeletable()) {
|
||||
if fs.IsTemporary(dirFile) || (matcher != nil && matcher.Match(fullDirFile).IsDeletable()) {
|
||||
f.fs.RemoveAll(fullDirFile)
|
||||
}
|
||||
}
|
||||
@@ -988,7 +988,7 @@ func (f *sendReceiveFolder) handleFile(file protocol.FileInfo, copyChan chan<- c
|
||||
return
|
||||
}
|
||||
|
||||
tempName := ignore.TempName(file.Name)
|
||||
tempName := fs.TempName(file.Name)
|
||||
|
||||
scanner.PopulateOffsets(file.Blocks)
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import (
|
||||
|
||||
"github.com/syncthing/syncthing/lib/db"
|
||||
"github.com/syncthing/syncthing/lib/fs"
|
||||
"github.com/syncthing/syncthing/lib/ignore"
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
"github.com/syncthing/syncthing/lib/scanner"
|
||||
"github.com/syncthing/syncthing/lib/sync"
|
||||
@@ -27,15 +26,15 @@ func TestMain(m *testing.M) {
|
||||
// We do this to make sure that the temp file required for the tests
|
||||
// does not get removed during the tests. Also set the prefix so it's
|
||||
// found correctly regardless of platform.
|
||||
if ignore.TempPrefix != ignore.WindowsTempPrefix {
|
||||
originalPrefix := ignore.TempPrefix
|
||||
ignore.TempPrefix = ignore.WindowsTempPrefix
|
||||
if fs.TempPrefix != fs.WindowsTempPrefix {
|
||||
originalPrefix := fs.TempPrefix
|
||||
fs.TempPrefix = fs.WindowsTempPrefix
|
||||
defer func() {
|
||||
ignore.TempPrefix = originalPrefix
|
||||
fs.TempPrefix = originalPrefix
|
||||
}()
|
||||
}
|
||||
future := time.Now().Add(time.Hour)
|
||||
err := os.Chtimes(filepath.Join("testdata", ignore.TempName("file")), future, future)
|
||||
err := os.Chtimes(filepath.Join("testdata", fs.TempName("file")), future, future)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -191,14 +190,14 @@ func TestCopierFinder(t *testing.T) {
|
||||
// After dropping out blocks found locally:
|
||||
// Pull: 1, 5, 6, 8
|
||||
|
||||
tempFile := filepath.Join("testdata", ignore.TempName("file2"))
|
||||
tempFile := filepath.Join("testdata", fs.TempName("file2"))
|
||||
err := os.Remove(tempFile)
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
existingBlocks := []int{0, 2, 3, 4, 0, 0, 7, 0}
|
||||
existingFile := setUpFile(ignore.TempName("file"), existingBlocks)
|
||||
existingFile := setUpFile(fs.TempName("file"), existingBlocks)
|
||||
requiredFile := existingFile
|
||||
requiredFile.Blocks = blocks[1:]
|
||||
requiredFile.Name = "file2"
|
||||
@@ -261,7 +260,7 @@ func TestCopierFinder(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestWeakHash(t *testing.T) {
|
||||
tempFile := filepath.Join("testdata", ignore.TempName("weakhash"))
|
||||
tempFile := filepath.Join("testdata", fs.TempName("weakhash"))
|
||||
var shift int64 = 10
|
||||
var size int64 = 1 << 20
|
||||
expectBlocks := int(size / protocol.BlockSize)
|
||||
@@ -466,12 +465,12 @@ func TestLastResortPulling(t *testing.T) {
|
||||
}
|
||||
|
||||
(<-finisherChan).fd.Close()
|
||||
os.Remove(filepath.Join("testdata", ignore.TempName("newfile")))
|
||||
os.Remove(filepath.Join("testdata", fs.TempName("newfile")))
|
||||
}
|
||||
|
||||
func TestDeregisterOnFailInCopy(t *testing.T) {
|
||||
file := setUpFile("filex", []int{0, 2, 0, 0, 5, 0, 0, 8})
|
||||
defer os.Remove("testdata/" + ignore.TempName("filex"))
|
||||
defer os.Remove("testdata/" + fs.TempName("filex"))
|
||||
|
||||
db := db.OpenMemory()
|
||||
|
||||
@@ -545,7 +544,7 @@ func TestDeregisterOnFailInCopy(t *testing.T) {
|
||||
|
||||
func TestDeregisterOnFailInPull(t *testing.T) {
|
||||
file := setUpFile("filex", []int{0, 2, 0, 0, 5, 0, 0, 8})
|
||||
defer os.Remove("testdata/" + ignore.TempName("filex"))
|
||||
defer os.Remove("testdata/" + fs.TempName("filex"))
|
||||
|
||||
db := db.OpenMemory()
|
||||
m := NewModel(defaultConfig, protocol.LocalDeviceID, "syncthing", "dev", db, nil)
|
||||
|
||||
Reference in New Issue
Block a user