forked from keybase/kbfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync_control_file.go
41 lines (34 loc) · 997 Bytes
/
sync_control_file.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
// Copyright 2017 Keybase Inc. All rights reserved.
// Use of this source code is governed by a BSD
// license that can be found in the LICENSE file.
package libdokan
import (
"fmt"
"github.com/keybase/kbfs/dokan"
"github.com/keybase/kbfs/libfs"
"github.com/keybase/kbfs/libkbfs"
"golang.org/x/net/context"
)
// SyncControlFile is a special file used to control sync
// settings.
type SyncControlFile struct {
specialWriteFile
folder *Folder
action libfs.SyncAction
}
// WriteFile implements writes for dokan.
func (f *SyncControlFile) WriteFile(ctx context.Context,
fi *dokan.FileInfo, bs []byte, offset int64) (n int, err error) {
f.folder.fs.logEnter(ctx,
fmt.Sprintf("SyncControlFile (f.action=%s) Write", f.action))
defer func() { f.folder.reportErr(ctx, libkbfs.WriteMode, err) }()
if len(bs) == 0 {
return 0, nil
}
err = f.action.Execute(
ctx, f.folder.fs.config, f.folder.getFolderBranch(), f.folder.h)
if err != nil {
return 0, err
}
return len(bs), nil
}