torrent directory fix

This commit is contained in:
Ben Sarmiento
2023-11-11 13:31:24 +01:00
parent 263b0e0039
commit fef389e10d
4 changed files with 21 additions and 19 deletions

View File

@@ -64,18 +64,18 @@ func (o Object) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
}
case DIRECTORY:
for el := o.fs.t.TorrentMap.Front(); el != nil; el = el.Next() {
item := el.Value
if item.InProgress {
torrent := el.Value
if torrent.InProgress {
continue
}
dirs = append(dirs, fuse.Dirent{
Name: item.AccessKey,
Name: torrent.AccessKey,
Type: fuse.DT_Dir,
})
}
case TORRENT:
torrent, _ := o.fs.t.TorrentMap.Get(o.name)
if torrent == nil {
if torrent == nil || torrent.InProgress {
return nil, syscall.ENOENT
}
for el := torrent.SelectedFiles.Front(); el != nil; el = el.Next() {
@@ -123,7 +123,7 @@ func (o Object) Lookup(ctx context.Context, name string) (fs.Node, error) {
}, nil
case TORRENT:
torrent, _ := o.fs.t.TorrentMap.Get(name)
torrent, _ := o.fs.t.TorrentMap.Get(o.name)
if torrent == nil {
return nil, syscall.ENOENT
}
@@ -138,7 +138,7 @@ func (o Object) Lookup(ctx context.Context, name string) (fs.Node, error) {
name: name,
file: file,
size: uint64(file.Bytes),
mtime: convertRFC3339toTime(torrent.LatestAdded),
mtime: convertRFC3339toTime(file.Added),
}, nil
}
return nil, syscall.ENOENT
@@ -174,8 +174,7 @@ func (o Object) Rename(ctx context.Context, req *fuse.RenameRequest, newDir fs.N
}
func convertRFC3339toTime(input string) time.Time {
layout := "2006-01-02T15:04:05.000Z"
t, err := time.Parse(layout, input)
t, err := time.Parse(time.RFC3339, input)
if err != nil {
return time.Now()
}