Limit number of simultaneous file extractions to prevent hardlock

Added helper extraction functions
chmod & chown is now set after a folder's extraction to prevent permission issues
This commit is contained in:
Caleb Gardner
2023-04-17 10:22:10 -05:00
parent 2ba4551fb9
commit d2c72f9464
5 changed files with 118 additions and 21 deletions
+37
View File
@@ -0,0 +1,37 @@
package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/CalebQ42/squashfs"
)
func main() {
verbose := flag.Bool("v", false, "Verbose")
ignore := flag.Bool("ip", false, "Ignore Permissions and extract all files/folders with 0755")
flag.Parse()
if len(flag.Args()) < 2 {
fmt.Println("Please provide a file name and extraction path")
os.Exit(0)
}
f, err := os.Open(flag.Arg(0))
if err != nil {
panic(err)
}
r, err := squashfs.NewReader(f)
if err != nil {
panic(err)
}
op := squashfs.DefaultOptions()
op.Verbose = *verbose
op.IgnorePerm = *ignore
n := time.Now()
err = r.ExtractWithOptions(flag.Arg(1), op)
if err != nil {
panic(err)
}
fmt.Println("Took:", time.Since(n))
}