torrent directory fix
This commit is contained in:
@@ -180,7 +180,6 @@ func (t *TorrentManager) getChecksum() string {
|
||||
}
|
||||
|
||||
checksum := fmt.Sprintf("%d%s%d", totalCount, torrents[0].ID, count)
|
||||
t.log.Debugf("Checksum: %s", checksum)
|
||||
return checksum
|
||||
}
|
||||
|
||||
@@ -291,8 +290,9 @@ func (t *TorrentManager) getMoreInfo(rdTorrent realdebrid.Torrent) *Torrent {
|
||||
continue
|
||||
}
|
||||
selectedFiles.Set(filepath.Base(file.Path), &File{
|
||||
File: file,
|
||||
Link: "", // no link yet
|
||||
File: file,
|
||||
Added: info.Added,
|
||||
Link: "", // no link yet
|
||||
})
|
||||
}
|
||||
if selectedFiles.Len() > len(info.Links) && info.Progress == 100 {
|
||||
@@ -386,6 +386,7 @@ func (t *TorrentManager) getDirectories(torrent *realdebrid.TorrentInfo) []strin
|
||||
default:
|
||||
t.log.Error("Unknown config version")
|
||||
}
|
||||
t.log.Debugf("Torrent %s is in directories %v", t.getName(torrent.Name, torrent.OriginalName), ret)
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -478,7 +479,8 @@ func (t *TorrentManager) organizeChaos(links []string, selectedFiles *orderedmap
|
||||
Bytes: result.Response.Filesize,
|
||||
Selected: 1,
|
||||
},
|
||||
Link: result.Response.Link,
|
||||
Added: time.Now().Format(time.RFC3339),
|
||||
Link: result.Response.Link,
|
||||
})
|
||||
} else {
|
||||
isChaotic = true
|
||||
|
||||
@@ -18,5 +18,6 @@ type Torrent struct {
|
||||
|
||||
type File struct {
|
||||
realdebrid.File
|
||||
Link string
|
||||
Added string
|
||||
Link string
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user