-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from rbtr/deleter
add deleter plugins
- Loading branch information
Showing
27 changed files
with
380 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
### File deleter processor | ||
The deleter processor marks files for deletion by the internal deletion output. This allows files with certain extensions, empty directories, or that match specified regexps to be deleted after Pachinko has finished sorting. | ||
|
||
#### Configuration | ||
The default deleter plugin configuration is: | ||
```yaml | ||
- categories: [] | ||
directories: true | ||
extensions: | ||
- 7z | ||
- gz | ||
- gzip | ||
- rar | ||
- tar | ||
- zip | ||
- bmp | ||
- gif | ||
- heic | ||
- jpeg | ||
- jpg | ||
- png | ||
- tiff | ||
- info | ||
- nfo | ||
- txt | ||
- website | ||
matchers: [] | ||
name: deleter | ||
``` | ||
|||| | ||
|-|-|-| | ||
|`categories`|`[]string`|[unimplemented] list of categories of file such as text or archive to remove.| | ||
|`directories`|`bool`|whether to remove directories. Even if true, only *empty* dirs will be removed.| | ||
|`extensions`|`[]string` | list of file extensions to remove.| | ||
|`matchers`|`[]string` | regexps to match files to remove.| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
Copyright © 2020 The Pachinko Authors | ||
This Source Code Form is subject to the terms of the Mozilla Public | ||
License, v. 2.0. If a copy of the MPL was not distributed with this | ||
file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
package output | ||
|
||
import ( | ||
"container/list" | ||
"context" | ||
"os" | ||
|
||
"github.com/rbtr/pachinko/plugin/output" | ||
"github.com/rbtr/pachinko/types" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
// Deleter is a deleter output used to clean up chaff | ||
type Deleter struct { | ||
DryRun bool | ||
} | ||
|
||
func (*Deleter) Init(context.Context) error { | ||
return nil | ||
} | ||
|
||
// Receive implements the Plugin interface on the Deleter | ||
func (d *Deleter) Receive(c <-chan types.Item) { | ||
log.Trace("started deleter output") | ||
q := list.New() | ||
for m := range c { | ||
log.Infof("deleter_output: received_input %#v", m) | ||
if m.Delete { | ||
log.Infof("deleter_output: queueing %s", m.SourcePath) | ||
q.PushBack(m) | ||
} | ||
} | ||
for e := q.Front(); e != nil; e = e.Next() { | ||
i := (e.Value).(types.Item) | ||
log.Infof("deleter_output: deleting %s", i.SourcePath) | ||
if d.DryRun { | ||
continue | ||
} | ||
if err := os.Remove(i.SourcePath); err != nil { | ||
log.Error(err) | ||
} | ||
} | ||
} | ||
|
||
func NewDeleter(dryRun bool) output.Output { | ||
return &Deleter{DryRun: dryRun} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.