saracen / fastzip Goto Github PK
View Code? Open in Web Editor NEWFastzip is an opinionated Zip archiver and extractor with a focus on speed.
License: MIT License
Fastzip is an opinionated Zip archiver and extractor with a focus on speed.
License: MIT License
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
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 :-?
the passwd is error when i use encrypt zip at the first once that i changed the passwd
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...
Does this library support preserving timestamps of symlinks?
See the problem report at gitlab.com:
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.
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?
We have a real interest to add support for Go on z/OS https://www.ibm.com/products/open-enterprise-sdk-go-zos. It is one of the two vendor requirements to be able to use fastzip with GitLab runner on z/OS.
See:
๐ 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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.