9
9
gopath "path"
10
10
"sort"
11
11
"strings"
12
+ "time"
12
13
13
14
humanize "github.com/dustin/go-humanize"
14
15
"github.com/ipfs/go-ipfs/core"
@@ -768,6 +769,8 @@ stat' on the file or any of its ancestors.
768
769
cmds .BoolOption (filesTruncateOptionName , "t" , "Truncate the file to size zero before writing." ),
769
770
cmds .Int64Option (filesCountOptionName , "n" , "Maximum number of bytes to read." ),
770
771
cmds .BoolOption (filesRawLeavesOptionName , "Use raw blocks for newly created leaf nodes. (experimental)" ),
772
+ // FIXME: Fake lock for manual testing. Remove.
773
+ cmds .IntOption ("lock-time" , "lt" , "[TESTING] timeout to hold the MFS lock while copying" ).WithDefault (0 ),
771
774
cidVersionOption ,
772
775
hashOption ,
773
776
},
@@ -792,20 +795,25 @@ stat' on the file or any of its ancestors.
792
795
if err != nil {
793
796
return err
794
797
}
798
+ filesRoot := nd .LockedFilesRoot .LockRoot ()
799
+ defer nd .LockedFilesRoot .UnlockRoot ()
800
+ // Keep the hold for a fake, arbitrary amount of time to test it manually.
801
+ timeout , _ := req .Options ["lock-time" ].(int )
802
+ defer time .Sleep (time .Duration (timeout ) * time .Second )
795
803
796
804
offset , _ := req .Options [filesOffsetOptionName ].(int64 )
797
805
if offset < 0 {
798
806
return fmt .Errorf ("cannot have negative write offset" )
799
807
}
800
808
801
809
if mkParents {
802
- err := ensureContainingDirectoryExists (nd . FilesRoot , path , prefix )
810
+ err := ensureContainingDirectoryExists (filesRoot , path , prefix )
803
811
if err != nil {
804
812
return err
805
813
}
806
814
}
807
815
808
- fi , err := getFileHandle (nd . FilesRoot , path , create , prefix )
816
+ fi , err := getFileHandle (filesRoot , path , create , prefix )
809
817
if err != nil {
810
818
return err
811
819
}
0 commit comments