1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

feat(remote): prefix checksums/cached files with the filename (#1636)

* feat(remote): add the task filename in the checksum / cache filename

* prefix the filename with the lastDir from the path
This commit is contained in:
Valentin Maerten
2024-06-28 18:07:43 +02:00
committed by GitHub
parent 46c5eafe35
commit 6012da7a21
5 changed files with 26 additions and 2 deletions

View File

@@ -50,9 +50,19 @@ func (c *Cache) key(node Node) string {
}
func (c *Cache) cacheFilePath(node Node) string {
return filepath.Join(c.dir, fmt.Sprintf("%s.yaml", c.key(node)))
return c.filePath(node, "yaml")
}
func (c *Cache) checksumFilePath(node Node) string {
return filepath.Join(c.dir, fmt.Sprintf("%s.checksum", c.key(node)))
return c.filePath(node, "checksum")
}
func (c *Cache) filePath(node Node, suffix string) string {
lastDir, filename := node.FilenameAndLastDir()
prefix := filename
// Means it's not "", nor "." nor "/", so it's a valid directory
if len(lastDir) > 1 {
prefix = fmt.Sprintf("%s-%s", lastDir, filename)
}
return filepath.Join(c.dir, fmt.Sprintf("%s.%s.%s", prefix, c.key(node), suffix))
}