node-modules / compressing

Everything you need for compressing and uncompressing
MIT License
431 stars 36 forks source link

file's ctime & mtime kept current time when uncompress #37

Open dickeylth opened 4 years ago

dickeylth commented 4 years ago

Using uncompress with file, the extracted files' create time and modified time are the same as current time, which lost the original create and modified time of the file itself.

using unzip from command line:

[admin@lapras /tmp]
$unzip ./60000001_1.8.0.5.amr -d ./600001_1.8.0.5
Archive:  ./60000001_1.8.0.5.amr
  inflating: ./600001_1.8.0.5/Manifest.xml
  inflating: ./600001_1.8.0.5/CERT.json
  inflating: ./600001_1.8.0.5/60000001.tar

[admin@lapras /tmp]
$cd 600001_1.8.0.5/

[admin@ /tmp/600001_1.8.0.5]
$ll
total 1080
-rw-r--r-- 1 admin admin 1095680 Feb  1 00:02 60000001.tar
-rw-r--r-- 1 admin admin     727 Feb  1 00:02 CERT.json
-rw-r--r-- 1 admin admin     132 Feb  1 00:02 Manifest.xml

using uncompress method:

const amrExtractPath = path.join(systemTempDir, amrFileName.replace(path.extname(amrFileName), ''));
await compressing.zip.uncompress(amrDestPath, amrExtractPath);

and the result:

[admin@lapras /tmp/600001_1.8.0.5]
$ll ../60000001_1.8.0.5
total 1084
drwxrwxr-x 3 admin admin    4096 Feb 17 22:11 60000001
-rw-rw-r-- 1 admin admin 1095680 Feb 17 22:26 60000001.tar
-rw-rw-r-- 1 admin admin     727 Feb 17 22:26 CERT.json
-rw-rw-r-- 1 admin admin     132 Feb 17 22:26 Manifest.xml