optimize name access
Some checks failed
docker / build-docker (linux/amd64) (push) Successful in 1m53s
docker / build-docker (linux/386) (push) Successful in 2m0s
docker / build-docker (linux/arm64) (push) Has been cancelled
docker / build-docker (linux/arm/v7) (push) Has been cancelled
docker / build-docker (linux/arm64/v8) (push) Has been cancelled

This commit is contained in:
royalcat 2024-06-17 00:44:09 +03:00
parent bc4b39b1c1
commit 667578f048
3 changed files with 3 additions and 9 deletions

View file

@ -35,20 +35,13 @@ type TorrentFS struct {
var _ vfs.Filesystem = (*TorrentFS)(nil) var _ vfs.Filesystem = (*TorrentFS)(nil)
func (s *Daemon) NewTorrentFs(ctx context.Context, f vfs.File) (vfs.Filesystem, error) { func (s *Daemon) NewTorrentFs(ctx context.Context, f vfs.File) (vfs.Filesystem, error) {
defer f.Close(ctx)
info, err := f.Info()
if err != nil {
return nil, err
}
c, err := s.LoadTorrent(ctx, f) c, err := s.LoadTorrent(ctx, f)
if err != nil { if err != nil {
return nil, err return nil, err
} }
return &TorrentFS{ return &TorrentFS{
name: info.Name(), name: f.Name(),
Torrent: c, Torrent: c,
resolver: vfs.NewResolver(vfs.ArchiveFactories), resolver: vfs.NewResolver(vfs.ArchiveFactories),
}, nil }, nil

View file

@ -126,7 +126,7 @@ func (c *CtxBillyFile) IsDir() bool {
// Name implements File. // Name implements File.
func (c *CtxBillyFile) Name() string { func (c *CtxBillyFile) Name() string {
return c.file.Name() return c.info.Name()
} }
// Read implements File. // Read implements File.

View file

@ -306,6 +306,7 @@ PARTS_LOOP:
if err != nil { if err != nil {
return "", nil, "", fmt.Errorf("error opening filesystem file: %s with error: %w", fsPath, err) return "", nil, "", fmt.Errorf("error opening filesystem file: %s with error: %w", fsPath, err)
} }
defer fsFile.Close(ctx)
nestedFs, err := nestFactory(ctx, fsFile) nestedFs, err := nestFactory(ctx, fsFile)
if err != nil { if err != nil {
return "", nil, "", fmt.Errorf("error creating filesystem from file: %s with error: %w", fsPath, err) return "", nil, "", fmt.Errorf("error creating filesystem from file: %s with error: %w", fsPath, err)