Removed close function from squashfs.File
This seems to cause issues in ver specific circumstances and ultimately, isn't needed.
This commit is contained in:
@@ -145,12 +145,6 @@ func (d *dataReader) readCurBlock() error {
|
||||
return err
|
||||
}
|
||||
|
||||
//Close frees up the curData from memory
|
||||
func (d *dataReader) Close() error {
|
||||
d.curData = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *dataReader) Read(p []byte) (int, error) {
|
||||
if d.curData == nil {
|
||||
err := d.readCurBlock()
|
||||
|
||||
@@ -356,7 +356,6 @@ func (f *File) ExtractWithOptions(path string, dereferenceSymlink, unbreakSymlin
|
||||
return
|
||||
}
|
||||
finishChan := make(chan []error)
|
||||
defer close(finishChan)
|
||||
for _, child := range children {
|
||||
go func(child *File) {
|
||||
if f.name == "" {
|
||||
@@ -408,7 +407,6 @@ func (f *File) ExtractWithOptions(path string, dereferenceSymlink, unbreakSymlin
|
||||
errs = append(errs, err)
|
||||
return
|
||||
}
|
||||
f.Close()
|
||||
fil.Chown(int(f.r.idTable[f.in.Header.UID]), int(f.r.idTable[f.in.Header.GID]))
|
||||
//don't mention anything when it fails. Because it fails often. Probably has something to do about uid & gid 0
|
||||
// if err != nil {
|
||||
@@ -480,21 +478,6 @@ func (f *File) ExtractWithOptions(path string, dereferenceSymlink, unbreakSymlin
|
||||
return
|
||||
}
|
||||
|
||||
//Close frees up the memory held up by the underlying reader. Should NOT be called when writing.
|
||||
//When reading, Close is safe to use, but any subsequent Read calls resets to the beginning of the file.
|
||||
func (f *File) Close() error {
|
||||
if f.IsDir() {
|
||||
return errNotFile
|
||||
}
|
||||
if f.Reader != nil {
|
||||
if closer, is := f.Reader.(io.Closer); is {
|
||||
closer.Close()
|
||||
}
|
||||
f.Reader = nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
//Read from the file. Doesn't do anything fancy, just pases it to the underlying io.Reader. If a directory, return io.EOF.
|
||||
func (f *File) Read(p []byte) (int, error) {
|
||||
if f.IsDir() {
|
||||
|
||||
@@ -57,15 +57,6 @@ func (r *Reader) newFileReader(in *inode.Inode) (*fileReader, error) {
|
||||
return &rdr, nil
|
||||
}
|
||||
|
||||
//Close runs Close on the data reader and frees the fragmentdata
|
||||
func (f *fileReader) Close() error {
|
||||
if f.data != nil {
|
||||
f.data.Close()
|
||||
}
|
||||
f.fragmentData = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
func (f *fileReader) Read(p []byte) (int, error) {
|
||||
if f.fragOnly {
|
||||
n, err := bytes.NewBuffer(f.fragmentData[f.read:]).Read(p)
|
||||
|
||||
+4
-3
@@ -11,8 +11,8 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
downloadURL = "https://github.com/Swordfish90/cool-retro-term/releases/download/1.1.1/Cool-Retro-Term-1.1.1-x86_64.AppImage"
|
||||
appImageName = "Cool-Retro-Term.AppImage"
|
||||
downloadURL = "https://github.com/srevinsaju/Firefox-Appimage/releases/download/firefox-v84.0.r20201221152838/firefox-84.0.r20201221152838-x86_64.AppImage"
|
||||
appImageName = "firefox-84.0.r20201221152838-x86_64.AppImage"
|
||||
squashfsName = "balenaEtcher-1.5.113-x64.AppImage.sfs" //testing with a ArchLinux root fs from the live img
|
||||
)
|
||||
|
||||
@@ -68,7 +68,8 @@ func TestAppImage(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
errs := rdr.ExtractTo(wd + "/testing/cool-retro")
|
||||
os.RemoveAll(wd + "testing/firefox")
|
||||
errs := rdr.ExtractTo(wd + "/testing/firefox")
|
||||
if len(errs) > 0 {
|
||||
t.Fatal(errs)
|
||||
}
|
||||
|
||||
@@ -14,12 +14,12 @@ import (
|
||||
//If AllowErrors is true, when errors are encountered, it just prints to the log instead of failing.
|
||||
type Writer struct {
|
||||
files map[string][]*File
|
||||
directories []string
|
||||
symlinkTable map[string]string //symlinkTable holds info about symlink'd to files that had to be moved from their original position. [originalpath]newpath
|
||||
symlinkTable map[string]string //[oldpath]newpath
|
||||
symTableTemp map[string]string
|
||||
directories []string
|
||||
compression int
|
||||
ResolveSymlinks bool
|
||||
AllowErrors bool
|
||||
compression int
|
||||
}
|
||||
|
||||
//NewWriter creates a new squashfs.Writer with the default settings (gzip compression, autoresolving symlinks, and allowErrors)
|
||||
@@ -51,8 +51,8 @@ func NewWriterWithOptions(resolveSymlinks, allowErrors bool, compressionType int
|
||||
}
|
||||
|
||||
type fileError struct {
|
||||
files []*File
|
||||
err error
|
||||
files []*File
|
||||
}
|
||||
|
||||
//convertFile converts the given os.File to a squashfs.File. Returns the errors and converted file to the channels.
|
||||
@@ -163,6 +163,7 @@ func (w *Writer) AddFilesToPath(squashfsPath string, files ...*os.File) error {
|
||||
for _, fil := range files {
|
||||
go w.convertFile(squashfsPath, fil, false, fileErrChan)
|
||||
}
|
||||
return errors.New("Not yet ready")
|
||||
}
|
||||
|
||||
//AddFiles adds all files given to the root directory
|
||||
|
||||
Reference in New Issue
Block a user