switch hardlink id from int64 to bytes

This commit is contained in:
Chris Lu
2020-09-24 11:11:42 -07:00
parent 4856bce0ee
commit 1012df7bb5
12 changed files with 29 additions and 33 deletions

View File

@@ -32,8 +32,8 @@ func (dir *Dir) Link(ctx context.Context, req *fuse.LinkRequest, old fs.Node) (f
}
// update old file to hardlink mode
if oldFile.entry.HardLinkId == 0 {
oldFile.entry.HardLinkId = util.RandomInt64()
if oldFile.entry.HardLinkId == nil {
oldFile.entry.HardLinkId = util.RandomBytes(16)
oldFile.entry.HardLinkCounter = 1
}
oldFile.entry.HardLinkCounter++

View File

@@ -253,7 +253,7 @@ func (file *File) Forget() {
}
func (file *File) maybeLoadEntry(ctx context.Context) error {
if (file.entry == nil || file.entry.HardLinkId != 0) && file.isOpen <= 0 {
if (file.entry == nil || len(file.entry.HardLinkId) != 0) && file.isOpen <= 0 {
entry, err := file.wfs.maybeLoadEntry(file.dir.FullPath(), file.Name)
if err != nil {
glog.V(3).Infof("maybeLoadEntry file %s/%s: %v", file.dir.FullPath(), file.Name, err)