mirror of
https://github.com/kopia/kopia.git
synced 2026-05-11 16:25:13 -04:00
Remove unused-parameter exclusion for `ctx` in revive linter. --------- Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Co-authored-by: Matthieu MOREL <matthieu.morel35@gmail.com>
39 lines
1.0 KiB
Go
39 lines
1.0 KiB
Go
package localfs
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/kopia/kopia/snapshot"
|
|
)
|
|
|
|
const (
|
|
// ShallowEntrySuffix is a suffix identifying placeholder files.
|
|
ShallowEntrySuffix = ".kopia-entry"
|
|
|
|
// dirMode is the FileMode for placeholder directories.
|
|
dirMode = 0o700
|
|
)
|
|
|
|
// TrimShallowSuffix returns the path without the placeholder suffix.
|
|
func TrimShallowSuffix(path string) string {
|
|
return strings.TrimSuffix(path, ShallowEntrySuffix)
|
|
}
|
|
|
|
// PlaceholderFilePath is a filesystem path of a shallow placeholder file or directory.
|
|
type PlaceholderFilePath string
|
|
|
|
// DirEntryOrNil returns the snapshot.DirEntry corresponding to this PlaceholderFilePath.
|
|
func (pf PlaceholderFilePath) DirEntryOrNil(_ context.Context) (*snapshot.DirEntry, error) {
|
|
path := string(pf)
|
|
if fi, err := os.Lstat(path); err == nil && fi.IsDir() {
|
|
return dirEntryFromPlaceholder(filepath.Join(path, ShallowEntrySuffix))
|
|
}
|
|
|
|
return dirEntryFromPlaceholder(path)
|
|
}
|
|
|
|
var _ snapshot.HasDirEntryOrNil = PlaceholderFilePath("")
|