Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0dd1d140f |
@@ -512,12 +512,16 @@ func (c *Cache) reconcileAccounting(ctx context.Context) error {
|
|||||||
return c.reconcileUsageTotal(ctx)
|
return c.reconcileUsageTotal(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
// reconcileVariantFiles walks the variant storage directory, checking
|
// reconcileFiles walks baseDir, one of the cache's storage directories,
|
||||||
// each variant file against its accounting row (reconcileVariantFile)
|
// sweeping stale temp files and passing each other file, with its name, to
|
||||||
// and sweeping stale temp files.
|
// reconcileFile. Once ctx is cancelled it stops at the next file and
|
||||||
func (c *Cache) reconcileVariantFiles(ctx context.Context) error {
|
// returns ctx's error.
|
||||||
|
func (c *Cache) reconcileFiles(
|
||||||
|
ctx context.Context, baseDir string,
|
||||||
|
reconcileFile func(path string, entry fs.DirEntry, name string) error,
|
||||||
|
) error {
|
||||||
return filepath.WalkDir(
|
return filepath.WalkDir(
|
||||||
c.variants.baseDir,
|
baseDir,
|
||||||
func(path string, entry fs.DirEntry, err error) error {
|
func(path string, entry fs.DirEntry, err error) error {
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
@@ -535,11 +539,21 @@ func (c *Cache) reconcileVariantFiles(ctx context.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.reconcileVariantFile(ctx, path, entry, imagerequest.VariantKey(name))
|
return reconcileFile(path, entry, name)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reconcileVariantFiles walks the variant storage directory, checking
|
||||||
|
// each variant file against its accounting row (reconcileVariantFile)
|
||||||
|
// and sweeping stale temp files.
|
||||||
|
func (c *Cache) reconcileVariantFiles(ctx context.Context) error {
|
||||||
|
return c.reconcileFiles(ctx, c.variants.baseDir,
|
||||||
|
func(path string, entry fs.DirEntry, name string) error {
|
||||||
|
return c.reconcileVariantFile(ctx, path, entry, imagerequest.VariantKey(name))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// reconcileVariantFile checks one variant file against its accounting
|
// reconcileVariantFile checks one variant file against its accounting
|
||||||
// row. A file without a row is adopted into the accounting, unless it is
|
// row. A file without a row is adopted into the accounting, unless it is
|
||||||
// empty. A file that is empty, or not the size its row records, as a
|
// empty. A file that is empty, or not the size its row records, as a
|
||||||
@@ -696,28 +710,10 @@ func queryStringColumn[T ~string](
|
|||||||
// each blob file against its source_content row (reconcileSourceFile)
|
// each blob file against its source_content row (reconcileSourceFile)
|
||||||
// and sweeping stale temp files.
|
// and sweeping stale temp files.
|
||||||
func (c *Cache) reconcileSourceFiles(ctx context.Context) error {
|
func (c *Cache) reconcileSourceFiles(ctx context.Context) error {
|
||||||
return filepath.WalkDir(
|
return c.reconcileFiles(ctx, c.srcContent.baseDir,
|
||||||
c.srcContent.baseDir,
|
func(path string, entry fs.DirEntry, name string) error {
|
||||||
func(path string, entry fs.DirEntry, err error) error {
|
|
||||||
if ctx.Err() != nil {
|
|
||||||
return ctx.Err()
|
|
||||||
}
|
|
||||||
|
|
||||||
if err != nil || entry.IsDir() {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
name := entry.Name()
|
|
||||||
|
|
||||||
if strings.HasPrefix(name, tempFilePrefix) {
|
|
||||||
c.sweepStaleTempFile(path, entry)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return c.reconcileSourceFile(ctx, path, entry, imagerequest.SourceKey(name))
|
return c.reconcileSourceFile(ctx, path, entry, imagerequest.SourceKey(name))
|
||||||
},
|
})
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// reconcileSourceFile checks one source blob file against its
|
// reconcileSourceFile checks one source blob file against its
|
||||||
|
|||||||
Reference in new issue
Block a user