Giter Site home page Giter Site logo

Comments (3)

oO0XX0Oo avatar oO0XX0Oo commented on July 24, 2024 1

Hi @saracen

Thanks for the quick answer! WithStageDirectory is a perfectly fine option (at least for me). As long as the last modified date isn't reset, everything is fine (I don't want to harm concurrency because I like Archiver for its incredible speed. E.g. Archiver vs 7-Zip: Archiver it's a lot faster for the test folder with 2000 files and 300 folders).

Additionally, thanks a lot for the example how to set up the temp folder and providing the necessary option to Archiver!

Take your time if you really want to look deeper into this 'issue', it isn't urgent (any more) :)

Merry Christmas!

from fastzip.

saracen avatar saracen commented on July 24, 2024

Hey @oO0XX0Oo

Unfortunately I'm not going to have a chance to look at this in detail probably for a week or so.

However, I think I know what the issue is: For concurrent archiving, where multiple files are compressed at the same time, a staging directory is used. This staging directory is by default the directory to be archived.

You can change the staging directory's location by passing the option: WithStageDirectory. Alternatively, using the option WithArchiverConcurrency(1) will stop concurrent archiving, and therefore also not create any files in the staging directory - but will impact performance.

For changing the staging directory, you could do something like this:

tmp, err := ioutil.TempDir("", "fastzip")
if err != nil {
   return err
}
defer os.RemoveAll(tmp) // delete tmp directory after archiving complete

a, err := fastzip.NewArchiver(w, "~/fastzip-archiving", fastzip.WithStageDirectory(tmp))
...

This will then use the operating system's default directory for temporary files. This isn't the default to avoid cross-filesystem problems. However, when this decision was made, I didn't foresee this directory modification date issue. I'll think on this further. At the very least, the documentation should make it clear that by default, the directory to be archived is used to stage files in (and then they're cleaned up).

from fastzip.

oO0XX0Oo avatar oO0XX0Oo commented on July 24, 2024

Unfortunately, a somehow related issue...

This is only valid for the Windows operating systems!

When Archiver stores the file dates from the files/folders inside the source path it sets the last modified time (sometimes it's called "birth time") to time.Now() instead of using the existing time.

The same goes for Extractor. When it extracts an archive, the last modified date is set to time.Now() as well...

Can you consider importing the times library: https://github.com/djherbis/times
and store/restore the correct last modified time instead?

Thanks a lot,
oO0XX0Oo

from fastzip.

Related Issues (9)

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.