recyclebin

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package recyclebin moves episode files Pilot deletes (replaced by an upgrade, or deleted from the UI) into a recycle bin folder instead of deleting them, as in Sonarr. Files keep their series/season folders inside the bin, and are deleted for good after the cleanup period.

With no recycle bin folder set, files are deleted permanently, which is the behavior before the recycle bin existed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service recycles files.

func New

func New(mm SettingsGetter, logger *slog.Logger) *Service

New creates a Service.

func (*Service) Cleanup

func (s *Service) Cleanup(ctx context.Context) (int, error)

Cleanup deletes files that have been in the recycle bin longer than the cleanup period, then removes folders left empty. It returns how many files were deleted. Nothing happens with no bin or a period of 0.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, path, libraryRoot string) (string, error)

Delete removes the file at path: into the recycle bin when one is set, otherwise permanently. libraryRoot (may be "") is the library the file belongs to; the file keeps its folders below it inside the bin. It returns where the file went ("" when deleted permanently). A file that is already gone is not an error.

If the settings can't be loaded the file is left alone and an error returned: never delete permanently when the user may have a bin set.

func (*Service) Empty

func (s *Service) Empty(ctx context.Context) (int, error)

Empty deletes everything in the recycle bin. It returns how many files were deleted.

func (*Service) Preserve

func (s *Service) Preserve(ctx context.Context, path, libraryRoot string) (string, error)

Preserve moves the file at path into the recycle bin when one is set, and otherwise leaves it alone. Use it just before overwriting a file: with no bin, the overwrite itself replaces it (atomically), and nothing is lost if the overwrite fails. Returns where the file went ("" when it was left in place).

type SettingsGetter

type SettingsGetter interface {
	Get(ctx context.Context) (mediamanagement.Settings, error)
}

SettingsGetter loads the media management settings, which hold the recycle bin folder and cleanup period.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL