mirror of
https://github.com/rclone/rclone.git
synced 2024-11-29 03:48:27 +08:00
cache: enable internal tests and fix race condition for them (#1928)
This commit is contained in:
parent
6f1ae00c7f
commit
ebbe77f525
4
cache/cache_internal_test.go
vendored
4
cache/cache_internal_test.go
vendored
|
@ -224,7 +224,6 @@ func TestInternalLargeWrittenContentMatches(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInternalLargeWrittenContentMatches2(t *testing.T) {
|
func TestInternalLargeWrittenContentMatches2(t *testing.T) {
|
||||||
t.Skip("FIXME disabled because it is unreliable")
|
|
||||||
cryptFs, boltDb := newLocalCacheCryptFs(t, "tilwcm2-local", "tilwcm2-cache", "tilwcm2-crypt", true, nil)
|
cryptFs, boltDb := newLocalCacheCryptFs(t, "tilwcm2-local", "tilwcm2-cache", "tilwcm2-crypt", true, nil)
|
||||||
defer cleanupFs(t, cryptFs, boltDb)
|
defer cleanupFs(t, cryptFs, boltDb)
|
||||||
|
|
||||||
|
@ -534,14 +533,12 @@ func readDataFromObj(t *testing.T, co fs.Object, offset, end int64, useSeek bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func cleanupFs(t *testing.T, f fs.Fs, b *cache.Persistent) {
|
func cleanupFs(t *testing.T, f fs.Fs, b *cache.Persistent) {
|
||||||
t.Skip("FIXME disabled because it is unreliable")
|
|
||||||
err := f.Features().Purge()
|
err := f.Features().Purge()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
b.Close()
|
b.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func newLocalCacheCryptFs(t *testing.T, localRemote, cacheRemote, cryptRemote string, purge bool, cfg map[string]string) (fs.Fs, *cache.Persistent) {
|
func newLocalCacheCryptFs(t *testing.T, localRemote, cacheRemote, cryptRemote string, purge bool, cfg map[string]string) (fs.Fs, *cache.Persistent) {
|
||||||
t.Skip("FIXME disabled because it is unreliable")
|
|
||||||
fstest.Initialise()
|
fstest.Initialise()
|
||||||
dbPath := filepath.Join(fs.CacheDir, "cache-backend", cacheRemote+".db")
|
dbPath := filepath.Join(fs.CacheDir, "cache-backend", cacheRemote+".db")
|
||||||
boltDb, err := cache.GetPersistent(dbPath, &cache.Features{PurgeDb: true})
|
boltDb, err := cache.GetPersistent(dbPath, &cache.Features{PurgeDb: true})
|
||||||
|
@ -628,7 +625,6 @@ func newLocalCacheCryptFs(t *testing.T, localRemote, cacheRemote, cryptRemote st
|
||||||
}
|
}
|
||||||
|
|
||||||
func newLocalCacheFs(t *testing.T, localRemote, cacheRemote string, cfg map[string]string) (fs.Fs, *cache.Persistent) {
|
func newLocalCacheFs(t *testing.T, localRemote, cacheRemote string, cfg map[string]string) (fs.Fs, *cache.Persistent) {
|
||||||
t.Skip("FIXME disabled because it is unreliable")
|
|
||||||
fstest.Initialise()
|
fstest.Initialise()
|
||||||
dbPath := filepath.Join(fs.CacheDir, "cache-backend", cacheRemote+".db")
|
dbPath := filepath.Join(fs.CacheDir, "cache-backend", cacheRemote+".db")
|
||||||
boltDb, err := cache.GetPersistent(dbPath, &cache.Features{PurgeDb: true})
|
boltDb, err := cache.GetPersistent(dbPath, &cache.Features{PurgeDb: true})
|
||||||
|
|
4
cache/storage_persistent.go
vendored
4
cache/storage_persistent.go
vendored
|
@ -528,6 +528,10 @@ func (b *Persistent) CleanChunksBySize(maxSize int64) {
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err == bolt.ErrDatabaseNotOpen {
|
||||||
|
// we're likely a late janitor and we need to end quietly as there's no guarantee of what exists anymore
|
||||||
|
return
|
||||||
|
}
|
||||||
fs.Errorf("cache", "cleanup failed: %v", err)
|
fs.Errorf("cache", "cleanup failed: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user