Skip to content

Commit

Permalink
Merge pull request #361 from Warfront1/feat/add-hook-for-extracted-no…
Browse files Browse the repository at this point in the history
…thing

Adds the extractednothing ExtractStatus
  • Loading branch information
davidnewhall authored Jan 18, 2024
2 parents 24230b6 + b5469d2 commit 27cc615
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

*.go text eol=lf
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change this line.
/unpackerr

# JetBrains IDEs: GoLand, IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
.idea/*

# The rest is probably fine.
/init/macos/*.app/Contents/MacOS/*
/rsrc*.syso
Expand Down
7 changes: 5 additions & 2 deletions pkg/unpackerr/folder.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ func (u *Unpackerr) folderXtractrCallback(resp *xtractr.Response) {
u.Printf("[Folder] Extraction Started: %s, items in queue: %d", resp.X.Name, resp.Queued)
folder.step = EXTRACTING //nolint:wsl
case errors.Is(resp.Error, xtractr.ErrNoCompressedFiles):
// Ignore "no compressed files" errors for folders.
delete(u.Map, resp.X.Name)
folder.step = EXTRACTEDNOTHING
u.Printf("[Folder] Nothing Extracted: %s: %v", resp.X.Name, resp.Error)
case resp.Error != nil:
folder.step = EXTRACTFAILED
Expand Down Expand Up @@ -410,6 +409,10 @@ func (u *Unpackerr) checkFolderStats() {
case WAITING == folder.step && elapsed >= u.StartDelay.Duration:
// The folder hasn't been written to in a while, extract it.
u.extractFolder(name, folder)
case EXTRACTEDNOTHING == folder.step:
// Ignore "no compressed files" errors for folders.
delete(u.Map, name)
delete(u.folders.Folders, name)
case EXTRACTFAILED == folder.step && elapsed >= u.RetryDelay.Duration &&
(u.MaxRetries == 0 || folder.retr < u.MaxRetries):
u.Retries++
Expand Down
7 changes: 5 additions & 2 deletions pkg/unpackerr/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ const (
DELETING
DELETEFAILED // unused
DELETED
EXTRACTEDNOTHING
)

// Desc makes ExtractStatus human readable.
func (status ExtractStatus) Desc() string {
if status > DELETED {
if status > EXTRACTEDNOTHING {
return "Unknown"
}

Expand All @@ -52,6 +53,7 @@ func (status ExtractStatus) Desc() string {
"Deleting",
"Delete Failed",
"Deleted",
"extractednothing",
}[status]
}

Expand All @@ -62,7 +64,7 @@ func (status ExtractStatus) MarshalText() ([]byte, error) {

// String turns a status into a short string.
func (status ExtractStatus) String() string {
if status > DELETED {
if status > EXTRACTEDNOTHING {
return "unknown"
}

Expand All @@ -77,6 +79,7 @@ func (status ExtractStatus) String() string {
"deleting",
"deletefailed",
"deleted",
"extractednothing",
}[status]
}

Expand Down

0 comments on commit 27cc615

Please sign in to comment.