Skip to content

File locked/in use issue #1037

@stl3

Description

@stl3

I'm having somewhat of a unique issue that I am unable to figure out on my own so I was hoping there's an answer to it. For a bit of background, I am using this project specifically only for playing videos, and discarding other files I consider useless (or at least have priority set to none). This worked fine for the most part up until v1.58.1 where I am able to delete the files that have None as priority:

	for _, file := range t.Files() {
		lowerPath := strings.ToLower(file.Path())

		switch {
		case strings.HasSuffix(lowerPath, ".srt"),
			strings.HasSuffix(lowerPath, ".sub"),
			strings.HasSuffix(lowerPath, ".ass"),
			strings.HasSuffix(lowerPath, ".vtt"):
			file.SetPriority(torrent.PiecePriorityHigh) // Subtitles first
		case file == largestFile:
			file.SetPriority(torrent.PiecePriorityNormal) // Main video normal
		default:
			file.SetPriority(torrent.PiecePriorityNone) // Everything else not important
		}
	}

When I upgraded to v1.60.0, I've had to set the following in order for the files to keep original names while downloading and not have .part as extension:

"github.com/anacrolix/torrent/storage"
"github.com/anacrolix/torrent/generics"
	clientConfig.DefaultStorage = storage.NewFileOpts(storage.NewFileClientOpts{
		ClientBaseDir: dataDir,
		UsePartFiles:  generics.Some(false),
	})

Now with those above, when I'm on v1.60.0 files that are set as file.SetPriority(torrent.PiecePriorityNone) cannot be deleted as they are locked/in use. How can I make it so it works like back on v1.58.1 where the None priority files can be deleted so when their files are recreated they are 0bytes like this:

Image

What am I doing wrong or missing?

Note: Yes I am aware there are cross "pollinated" boundary pieces shared - I was aware of this when I had been doing it on previous versions, but now in v1.60.0 all files in torrent are locked/in use no matter what unlike in versions below v1.58.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions