-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
unstage_file.go
29 lines (25 loc) · 966 Bytes
/
unstage_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
// Copyright 2016 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 (
"github.com/keybase/client/go/kbfs/dokan"
"github.com/keybase/client/go/kbfs/libfs"
"github.com/keybase/client/go/kbfs/libkbfs"
"golang.org/x/net/context"
)
// UnstageFile represents a write-only file when any write of at least
// one byte triggers unstaging all unmerged commits and
// fast-forwarding to the current master.
type UnstageFile struct {
folder *Folder
specialWriteFile
}
// WriteFile implements writes for dokan.
func (f *UnstageFile) WriteFile(ctx context.Context, fi *dokan.FileInfo, bs []byte, offset int64) (n int, err error) {
f.folder.fs.logEnter(ctx, "UnstageFile WriteFile")
defer func() { f.folder.reportErr(ctx, libkbfs.WriteMode, err) }()
return libfs.UnstageForTesting(
ctx, f.folder.fs.log, f.folder.fs.config,
f.folder.getFolderBranch(), bs)
}