length: fileInfo.Length,
}
if f.length == 0 {
- err = CreateNativeZeroLengthFile(f.path)
+ err = CreateNativeZeroLengthFile(PathShortener(f.path))
if err != nil {
err = fmt.Errorf("creating zero length file: %w", err)
return
// Returns EOF on short or missing file.
func (fst *fileTorrentImplIO) readFileAt(file file, b []byte, off int64) (n int, err error) {
fdRCacheM.Lock()
- centry := fdRCache[file.path]
+ pth := PathShortener(file.path)
+ centry := fdRCache[pth]
if centry == nil {
var fd *os.File
- fd, err = os.Open(file.path)
+ fd, err = os.Open(pth)
if os.IsNotExist(err) {
// File missing is treated the same as a short file.
err = io.EOF
return
}
centry = &fdCacheEntry{fd: fd}
- fdRCache[file.path] = centry
+ fdRCache[pth] = centry
}
fdRCacheM.Unlock()
// Limit the read to within the expected bounds of this file.
func (fst fileTorrentImplIO) WriteAt(p []byte, off int64) (n int, err error) {
fst.fts.segmentLocater.Locate(segments.Extent{off, int64(len(p))}, func(i int, e segments.Extent) bool {
- name := fst.fts.files[i].path
+ name := PathShortener(fst.fts.files[i].path)
_, ok := fdMkdirAllCache[filepath.Dir(name)]
if !ok {
os.MkdirAll(filepath.Dir(name), 0o777)