返回 DeepSeek-Reasonix
lock_fs.go
根目录 / internal / remote / bootstrap / lock_fs.go
1 package bootstrap
2
3 import (
4 "context"
5 "errors"
6 "io/fs"
7 "os"
8
9 "github.com/pkg/sftp"
10
11 "reasonix/internal/remote/sftpfs"
12 )
13
14 type serveLockFS interface {
15 MkdirAll(context.Context, string) error
16 MkdirExclusive(context.Context, string) error
17 Stat(context.Context, string) (sftpfs.Entry, error)
18 ReadFile(context.Context, string, int64) ([]byte, bool, sftpfs.Kind, error)
19 WriteFileAtomic(context.Context, string, []byte, fs.FileMode) error
20 Remove(context.Context, string, bool) error
21 }
22
23 func lockCreationMayContend(err error) bool {
24 if errors.Is(err, os.ErrExist) {
25 return true
26 }
27 var status *sftp.StatusError
28 return errors.As(err, &status) && status.FxCode() == sftp.ErrSSHFxFailure
29 }
30
30 lines GO