diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-07-21 16:34:28 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-07-22 15:17:25 +0300 |
commit | 252ce303cb3b0521701b6d0e3010f2920abacf9b (patch) | |
tree | ea685c5eeffd70be4a4b2564a111ad5aad8d49e7 | |
parent | c223c9e57979c0404a78904791c3c045dce0d433 (diff) |
tempdir: Remove storage-related constants and functions
Now that all callers use the locator instead of the tempdir package to
locate state, cache and temporary directories, this commit removes the
now-unused old interface. Furthermore, we also rename the code file to
"clean.go" given that it only cares about cleanup now, not about
storages anymore.
-rw-r--r-- | internal/tempdir/clean.go (renamed from internal/tempdir/storage.go) | 49 | ||||
-rw-r--r-- | internal/tempdir/clean_test.go (renamed from internal/tempdir/storage_test.go) | 0 |
2 files changed, 8 insertions, 41 deletions
diff --git a/internal/tempdir/storage.go b/internal/tempdir/clean.go index 69a1c13a2..0bef52c3e 100644 --- a/internal/tempdir/storage.go +++ b/internal/tempdir/clean.go @@ -17,47 +17,14 @@ import ( ) const ( - // GitalyDataPrefix is the top-level directory we use to store system - // (non-user) data. We need to be careful that this path does not clash - // with any directory name that could be provided by a user. The '+' - // character is not allowed in GitLab namespaces or repositories. - GitalyDataPrefix = config.GitalyDataPrefix - - // tmpRootPrefix is the directory in which we store temporary - // directories. - tmpRootPrefix = GitalyDataPrefix + "/tmp" - - // cachePrefix is the directory where all cache data is stored on a - // storage location. - cachePrefix = GitalyDataPrefix + "/cache" - - // statePrefix is the directory where all state data is stored on a - // storage location. - statePrefix = GitalyDataPrefix + "/state" - - // MaxAge is used by ForDeleteAllRepositories. It is also a fallback - // for the context-scoped temporary directories, to ensure they get - // cleaned up if the cleanup at the end of the context failed to run. - MaxAge = 7 * 24 * time.Hour -) - -// CacheDir returns the path to the cache dir for a storage location -func CacheDir(storage config.Storage) string { return AppendCacheDir(storage.Path) } - -// AppendCacheDir will append the cache directory convention to the storage path -// provided -func AppendCacheDir(storagePath string) string { return filepath.Join(storagePath, cachePrefix) } + // tmpRootPrefix is the directory in which we store temporary directories. + tmpRootPrefix = config.GitalyDataPrefix + "/tmp" -// AppendStateDir will append the state directory convention to the storage path -// provided -func AppendStateDir(storagePath string) string { return filepath.Join(storagePath, statePrefix) } - -// TempDir returns the path to the temp dir for a storage location -func TempDir(storage config.Storage) string { return AppendTempDir(storage.Path) } - -// AppendTempDir will append the temp directory convention to the storage path -// provided -func AppendTempDir(storagePath string) string { return filepath.Join(storagePath, tmpRootPrefix) } + // maxAge is used by ForDeleteAllRepositories. It is also a fallback for the context-scoped + // temporary directories, to ensure they get cleaned up if the cleanup at the end of the + // context failed to run. + maxAge = 7 * 24 * time.Hour +) // StartCleaning starts tempdir cleanup in a goroutine. func StartCleaning(locator storage.Locator, storages []config.Storage, d time.Duration) { @@ -112,7 +79,7 @@ func clean(locator storage.Locator, storage config.Storage) error { } for _, info := range entries { - if time.Since(info.ModTime()) < MaxAge { + if time.Since(info.ModTime()) < maxAge { continue } diff --git a/internal/tempdir/storage_test.go b/internal/tempdir/clean_test.go index 0e13c9589..0e13c9589 100644 --- a/internal/tempdir/storage_test.go +++ b/internal/tempdir/clean_test.go |