Giter Site home page Giter Site logo

fastzip's People

Contributors

kumbayo avatar saracen avatar streppel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

fastzip's Issues

Zips created in windows are not valid in linux due to the invalid separator

Even if Archive is provided with the files map that has "/" separator in keys it is changed to "\" in the system calls in the ArchiveWithContext. When "\" is used as separator linux sees invalid folder structure.

Fix: in ArchiveWithContext change

fileInfoHeader(rel, fi, hdr)

to

fileInfoHeader(strings.ReplaceAll(rel, "\\", "/"), fi, hdr)

or some similar solution using os.PathSeparator

zip: not a valid zip file

I copied the README code almost verbatim as far as I can tell, but I'm seeing this error

panic: zip: not a valid zip file

My code:

package main

import (
	"context"
	"os"
	"path/filepath"

	"github.com/saracen/fastzip"
)

func main() {
	sourceDir := "util/"
	zipFile := "test.zip"
	w, err := os.Create(zipFile)
	if err != nil {
		panic(err)
	}
	defer w.Close()

	a, err := fastzip.NewArchiver(w, sourceDir)
	if err != nil {
		panic(err)
	}
	defer a.Close()

	files := make(map[string]os.FileInfo)
	err = filepath.Walk(sourceDir, func(pathname string, info os.FileInfo, err error) error {
		files[pathname] = info
		return nil
	})

	if err = a.Archive(context.Background(), files); err != nil {
		panic(err)
	}

	e, err := fastzip.NewExtractor(zipFile, "./")
	if err != nil {
		panic(err) // PANICS
	}
	defer e.Close()

	if err = e.Extract(context.Background()); err != nil {
		panic(err)
	}
}

When I unzip the file in OSX Finder, it works just fine :-?

Archiver modifies the last modified date of the folder to archive

Hi,

I'm on MS Windows and when I use your "Archiver example" from the readme.me, the last modified date of the folder to archive is changed to now().

Instead of ~/fastzip-archiving
I'm using R:/tst_zip/zip me" which contains about 2000 files and 300 folders

Is there a way to avoid this behavior? I know that the last modified date is not know on linux but it is on Windows and it shouldn't be reset only because the folder gets zipped...

Decompressed file content is messed up

I'm archiving a folder containing .git/config file with fastzip on Linux, following the example shown in README.

When extracting said file, I'm expecting to see:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
[remote "origin"]
        url = ...
[receive]
        denyNonFastForwards = false
        denyCurrentBranch = ignore
        denyDeleteCurrent = ignore

However, I get:

<..J.@^PE.._1.^CL..Z^H..>.(.%."..$;..Sfg+.{..>^....w,x0...3).yb.VO(.8A^KkSM^T0....JAS^MV.0....^E#+...fJ....^Dh..^^....N.....g.v]7........9....4w^O..5...^X.fR_.^[..^?I\.^Xy.qH..v.t~...Y.,?V.|...]^Q../b...^B....

This happens with both golang sdk (using NewExtractor) and with traditional unix tar command.
Worth mentioning, is that this is only the case when using the default Deflate compression method. Using 0 (Store) method works fine (no compression though, which is expected).

I'd appreciate any help with this issue.

EDIT: Compressing only the file itself (as opposed to the folder containing it) seems to work fine.

Prevent unnecessary directory in zip?

When using fastzip, by default, there will be a single directory at the top level of the zip, which contains everything.

Is there a way to not have this top level directory?

add custom root folder during archival?

๐Ÿ‘‹ I'm trying to compress a bunch of files and have everything inside a root folder (its name differs from the source directory).

So given

/tmp/source-dir
   /A.txt
   /B.txt

would create a ZIP file with a structure like this:

/myroot
   /A.txt
   /B.txt

I can't get the myroot root directory working without renaming the original source dir (not an option, unfortunately). I tried using symlinks (seems to compress symlink itself, not follow it?) and changing the file path in the filepath.Walk function (results in "file not found").

Is there a way to do this?

PS: I can't do this on the extract, since I have no control over that part

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.