-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathjob_folder.go
53 lines (46 loc) · 997 Bytes
/
job_folder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package putiosync
import (
"context"
"fmt"
"os"
"path/filepath"
)
type createLocalFolderJob struct {
relpath string
remoteID int64
}
func (j *createLocalFolderJob) String() string {
return "Creating local folder " + j.relpath
}
func (j *createLocalFolderJob) Run(ctx context.Context) error {
err := os.MkdirAll(filepath.Join(localPath, filepath.FromSlash(j.relpath)), 0777)
if err != nil {
return err
}
s := stateType{
Status: statusSynced,
IsDir: true,
RemoteID: j.remoteID,
relpath: j.relpath,
}
return s.Write()
}
type createRemoteFolderJob struct {
relpath string
}
func (j *createRemoteFolderJob) String() string {
return fmt.Sprintf("Creating remote folder %q", j.relpath)
}
func (j *createRemoteFolderJob) Run(ctx context.Context) error {
remoteID, err := dirCache.Mkdirp(ctx, j.relpath)
if err != nil {
return err
}
s := stateType{
Status: statusSynced,
IsDir: true,
RemoteID: remoteID,
relpath: j.relpath,
}
return s.Write()
}