backend: refactor backend Connections and HasAtomicReplace into Properties

This commit is contained in:
Michael Eischer
2025-02-16 22:27:58 +01:00
parent 5ddda7f5e9
commit c970e58739
18 changed files with 89 additions and 97 deletions

View File

@@ -264,8 +264,11 @@ func Create(ctx context.Context, cfg Config) (*SFTP, error) {
return open(sftp, cfg)
}
func (r *SFTP) Connections() uint {
return r.Config.Connections
func (r *SFTP) Properties() backend.Properties {
return backend.Properties{
Connections: r.Config.Connections,
HasAtomicReplace: r.posixRename,
}
}
// Hasher may return a hash function for calculating a content hash for the backend
@@ -273,11 +276,6 @@ func (r *SFTP) Hasher() hash.Hash {
return nil
}
// HasAtomicReplace returns whether Save() can atomically replace files
func (r *SFTP) HasAtomicReplace() bool {
return r.posixRename
}
// tempSuffix generates a random string suffix that should be sufficiently long
// to avoid accidental conflicts
func tempSuffix() string {