github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/kbfs/libdokan/unstage_file.go (about) 1 // Copyright 2016 Keybase Inc. All rights reserved. 2 // Use of this source code is governed by a BSD 3 // license that can be found in the LICENSE file. 4 5 package libdokan 6 7 import ( 8 "github.com/keybase/client/go/kbfs/dokan" 9 "github.com/keybase/client/go/kbfs/libfs" 10 "github.com/keybase/client/go/kbfs/libkbfs" 11 "golang.org/x/net/context" 12 ) 13 14 // UnstageFile represents a write-only file when any write of at least 15 // one byte triggers unstaging all unmerged commits and 16 // fast-forwarding to the current master. 17 type UnstageFile struct { 18 folder *Folder 19 specialWriteFile 20 } 21 22 // WriteFile implements writes for dokan. 23 func (f *UnstageFile) WriteFile(ctx context.Context, fi *dokan.FileInfo, bs []byte, offset int64) (n int, err error) { 24 f.folder.fs.logEnter(ctx, "UnstageFile WriteFile") 25 defer func() { f.folder.reportErr(ctx, libkbfs.WriteMode, err) }() 26 return libfs.UnstageForTesting( 27 ctx, f.folder.fs.log, f.folder.fs.config, 28 f.folder.getFolderBranch(), bs) 29 }