Skip to content

Commit

Permalink
fix file identifier for darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
SweetMnM committed Nov 11, 2022
1 parent c36b7bb commit c4162e4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
17 changes: 17 additions & 0 deletions hardlinkfilemap/fileidentifier_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package hardlinkfilemap

import (
"errors"
"os"
"strconv"
"syscall"
)

func FileIdentifier(fi os.FileInfo) (string, error) {
sys, ok := fi.Sys().(*syscall.Stat_t)
if !ok {
return "", errors.New("failed to get file identifier")
}

return strconv.FormatInt(int64(sys.Dev), 10) + "|" + strconv.FormatUint(sys.Ino, 10), nil
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build !windows && !plan9

package hardlinkfilemap

import (
Expand Down
4 changes: 0 additions & 4 deletions hardlinkfilemap/hardlinkfilemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ func (t *HardlinkFileMap) IsTorrentUnique(torrent config.Torrent) bool {
return false
}

t.log.Infof("File: %s - ID: %s", f, id)
// preview the file id entry
t.log.Infof("File ID Entry: %v", t.hardlinkFileMap[id])

if paths, exists := t.hardlinkFileMap[id]; exists && len(paths) > 1 {
return false
}
Expand Down

0 comments on commit c4162e4

Please sign in to comment.