thrau / jarchivelib

A simple archiving and compression library for Java
https://github.com/thrau/jarchivelib
Apache License 2.0
198 stars 36 forks source link

Permissions are not restored if entries are extracted one-by-one #57

Closed abarsov closed 6 years ago

abarsov commented 6 years ago

It seems the reason is that FileModeMapper.map(entry, file); is called in CommonsArchiveEntry#extract before file was actually extracted.

@Override
    public File extract(File destination) throws IOException, IllegalStateException, IllegalArgumentException {
        assertState();
        IOUtils.requireDirectory(destination);

        File file = new File(destination, entry.getName());

        FileModeMapper.map(entry, file);

        if (entry.isDirectory()) {
            file.mkdirs();
        } else {
            file.getParentFile().mkdirs();
            IOUtils.copy(stream, file);
        }

        return file;
    }
thrau commented 6 years ago

great catch, thank you. should be fixed and deployed in 0.8.0-SNAPSHOT