2014-09-10 7 views
0

저는 TrueZip (v 7.6.4)을 사용하여 zip 아카이브에 기록합니다. 나는이 같은 일련의 폴더가 있습니다TrueZip 및 심볼릭 링크를 사용하여 아카이브에서 쓰기 문제

package com.tests.forstackoverflow.truezip; 

import java.io.File; 
import java.io.Writer; 

import org.slf4j.Logger; 
import org.slf4j.LoggerFactory; 

import de.schlichtherle.truezip.file.TFile; 
import de.schlichtherle.truezip.file.TFileWriter; 
import de.schlichtherle.truezip.file.TVFS; 
import de.schlichtherle.truezip.fs.FsSyncException; 

public class TestTz 
{ 
    Logger logger = LoggerFactory.getLogger(getClass()); 

    public void writeInArchive(String archiveName) 
    { 
     final File f = new TFile(new File(archiveName) + "/hello.txt"); 
     try (Writer writer = new TFileWriter(f)) 
     { 
      writer.write("Hello World!\n"); 
     } 
     catch(Exception e) 
     { 
      logger.error("Exception raised:", e); 
     } 
     try { TVFS.umount(); } catch(FsSyncException e) { logger.error("umount error", e); } 
    } 

    public static void main(String args[]) 
    { 
     TestTz test = new TestTz(); 

     test.writeInArchive("/home/remi/testtz/hello.zip"); 

     test.writeInArchive("/home/remi/symlink/hello.zip"); 

     test.writeInArchive("/home/remi/testtz/symlink/hello2.zip"); 

    } 
} 

먼저 호출에 writeInArchive 잘 작동 : 여기

> ls -l /home/remi 
drwxr-xr-x 2 remi remi 4096 sept. 10 16:49 testtz 
drwxr-xr-x 2 remi remi 4096 sept. 10 16:49 symlinktarget 
lrwxrwxrwx 1 remi remi 14 sept. 10 16:47 symlink -> symlinktarget/ 
> ls -l /home/remi/testtz 
lrwxrwxrwx 1 remi remi 25 sept. 10 16:47 symlink -> /home/remi/symlinktarget/ 

는 코드입니다.

sept. 10, 2014 4:49:55 PM com.tests.forstackoverflow.truezip.TestTz writeInArchive 
Grave: Exception raised: 
java.io.FileNotFoundException: /home/remi/symlink/hello.zip/hello.txt 
    at de.schlichtherle.truezip.file.TFileOutputStream.newOutputStream(TFileOutputStream.java:147) 
    at de.schlichtherle.truezip.file.TFileOutputStream.<init>(TFileOutputStream.java:116) 
    at de.schlichtherle.truezip.file.TFileWriter.<init>(TFileWriter.java:42) 
    at com.tests.forstackoverflow.truezip.TestTz.writeInArchive(TestTz.java:21) 
    at com.tests.forstackoverflow.truezip.TestTz.main(TestTz.java:38) 
Caused by: java.nio.file.FileAlreadyExistsException: /home/remi/symlink 
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:88) 
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) 
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) 
    at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:383) 
    at java.nio.file.Files.createDirectory(Files.java:628) 
    at java.nio.file.Files.createAndCheckIsDirectory(Files.java:732) 
    at java.nio.file.Files.createDirectories(Files.java:681) 
    at de.schlichtherle.truezip.fs.nio.file.FileOutputSocket.begin(FileOutputSocket.java:97) 
    at de.schlichtherle.truezip.fs.nio.file.FileOutputSocket.newOutputStream(FileOutputSocket.java:211) 
    at de.schlichtherle.truezip.fs.archive.zip.OptionOutputSocket.newOutputStream(OptionOutputSocket.java:48) 
    at de.schlichtherle.truezip.fs.archive.zip.ZipDriver.newOutputShop(ZipDriver.java:589) 
    at de.schlichtherle.truezip.fs.archive.zip.ZipDriver.newOutputShop0(ZipDriver.java:579) 
    at de.schlichtherle.truezip.fs.archive.zip.ZipDriver.newOutputShop(ZipDriver.java:564) 
    at de.schlichtherle.truezip.fs.FsTargetArchiveController.makeOutputArchive(FsTargetArchiveController.java:247) 
    at de.schlichtherle.truezip.fs.FsTargetArchiveController.mount0(FsTargetArchiveController.java:182) 
    at de.schlichtherle.truezip.fs.FsTargetArchiveController.mount(FsTargetArchiveController.java:155) 
    at de.schlichtherle.truezip.fs.FsFileSystemArchiveController$ResetFileSystem.autoMount(FsFileSystemArchiveController.java:85) 
    at de.schlichtherle.truezip.fs.FsFileSystemArchiveController.autoMount(FsFileSystemArchiveController.java:37) 
    at de.schlichtherle.truezip.fs.FsBasicArchiveController$1Output.mknod(FsBasicArchiveController.java:273) 
    at de.schlichtherle.truezip.fs.FsBasicArchiveController$1Output.newOutputStream(FsBasicArchiveController.java:233) 
    at de.schlichtherle.truezip.fs.FsContextController$Output.newOutputStream(FsContextController.java:322) 
    at de.schlichtherle.truezip.fs.FsResourceController$Output.newOutputStream(FsResourceController.java:273) 
    at de.schlichtherle.truezip.socket.DelegatingOutputSocket.newOutputStream(DelegatingOutputSocket.java:57) 
    at de.schlichtherle.truezip.fs.FsSyncController$Output.newOutputStream(FsSyncController.java:432) 
    at de.schlichtherle.truezip.fs.FsLockController$Output$1NewOutputStream.call(FsLockController.java:509) 
    at de.schlichtherle.truezip.fs.FsLockController$Output$1NewOutputStream.call(FsLockController.java:506) 
    at de.schlichtherle.truezip.fs.FsLockController.locked(FsLockController.java:328) 
    at de.schlichtherle.truezip.fs.FsLockController.writeLocked(FsLockController.java:268) 
    at de.schlichtherle.truezip.fs.FsLockController$Output.newOutputStream(FsLockController.java:513) 
    at de.schlichtherle.truezip.fs.FsFinalizeController$Output.newOutputStream(FsFinalizeController.java:209) 
    at de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController$1Output$NewOutputStream.call(FsFalsePositiveArchiveController.java:409) 
    at de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController$1Output$NewOutputStream.call(FsFalsePositiveArchiveController.java:402) 
    at de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController$TryChild.call(FsFalsePositiveArchiveController.java:507) 
    at de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController.call(FsFalsePositiveArchiveController.java:104) 
    at de.schlichtherle.truezip.fs.FsFalsePositiveArchiveController$1Output.newOutputStream(FsFalsePositiveArchiveController.java:399) 
    at de.schlichtherle.truezip.file.TFileOutputStream.newOutputStream(TFileOutputStream.java:143) 
    ... 4 more 
+0

TrueZIP 및 JDK를 모두 최신 버전으로 업데이트하고이 테스트를 반복하십시오. 이 문제가 해결 될 것으로 판단됩니다. –

+0

방금 ​​TrueZip 7.7.6 및 최신 JDK7을 사용해 보았지만 오류가 여전히 있습니다. JDK8/9를 사용해야한다는 것을 의미합니까? – remi

답변

0

은 기존 프로젝트에 TrueZip를 추가 : 다음과 같은 예외를 발생 (마지막 디렉토리는 아카이브 경로 심볼릭 링크를 제공합니다) 후속 호출? 그렇다면 프로젝트에 Truezip-driver-zip 종속성을 포함시켜야합니다. The maven repo for it is here. 이것을 프로젝트로 가져올 필요는 없지만 프로젝트에 내장 된 종속성 병이 필요합니다. Maven을 사용하지 않는다면, 빌드 프로세스를 포함시켜야한다.