Liron Aravot has posted comments on this change. Change subject: core: Adding support for OutMemoryTar ......................................................................
Patch Set 4: (7 comments) http://gerrit.ovirt.org/#/c/29039/4/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/archivers/tar/InMemoryTar.java File backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/archivers/tar/InMemoryTar.java: Line 21: tarArchiveOutputStream.closeArchiveEntry(); Line 22: } Line 23: Line 24: @Override Line 25: public void close() throws IOException { please remove from this patch Line 26: tarArchiveOutputStream.close(); Line 27: } http://gerrit.ovirt.org/#/c/29039/4/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/archivers/tar/OutMemoryTar.java File backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/archivers/tar/OutMemoryTar.java: Line 8: Line 9: import org.apache.commons.compress.archivers.tar.TarArchiveEntry; Line 10: import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; Line 11: Line 12: public class OutMemoryTar implements AutoCloseable { OutMemoryTar has no meaning, please change to TarInMemoryExport Line 13: Line 14: private TarArchiveInputStream tarInputStream; Line 15: Line 16: public OutMemoryTar(InputStream inputStream) { Line 16: public OutMemoryTar(InputStream inputStream) { Line 17: tarInputStream = new TarArchiveInputStream(inputStream); Line 18: Line 19: } Line 20: please add comment here specifying that it doesn't support tar with directories Line 21: public Map<String, String> unTar() throws IOException { Line 22: Map<String, String> fileToContent = new HashMap<>(); Line 23: TarArchiveEntry tarEntry = null; Line 24: tarEntry = tarInputStream.getNextTarEntry(); Line 18: Line 19: } Line 20: Line 21: public Map<String, String> unTar() throws IOException { Line 22: Map<String, String> fileToContent = new HashMap<>(); /s/fileToContent/fileContent Line 23: TarArchiveEntry tarEntry = null; Line 24: tarEntry = tarInputStream.getNextTarEntry(); Line 25: String fileData; Line 26: while (tarEntry != null) { Line 21: public Map<String, String> unTar() throws IOException { Line 22: Map<String, String> fileToContent = new HashMap<>(); Line 23: TarArchiveEntry tarEntry = null; Line 24: tarEntry = tarInputStream.getNextTarEntry(); Line 25: String fileData; please move the decleration to where it's used Line 26: while (tarEntry != null) { Line 27: // Get Size of the file and create a byte array for the size. Line 28: byte[] content = new byte[(int) tarEntry.getSize()]; Line 29: Line 28: byte[] content = new byte[(int) tarEntry.getSize()]; Line 29: Line 30: // Read file from the archive into byte array. Line 31: try (InputStream is = new FileInputStream(tarEntry.getFile());) { Line 32: is.read(content); the two lines below should be outside the try clause Line 33: fileData = new String(content); Line 34: fileToContent.put(tarEntry.getName(), fileData); Line 35: } Line 36: } Line 33: fileData = new String(content); Line 34: fileToContent.put(tarEntry.getName(), fileData); Line 35: } Line 36: } Line 37: tarEntry = tarInputStream.getNextTarEntry(); this should be in the while loop, no outside as it is now. Line 38: return fileToContent; Line 39: } Line 40: Line 41: @Override -- To view, visit http://gerrit.ovirt.org/29039 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie4fbc12337c16baca4be8a82d4a51b8b3ab0af4a Gerrit-PatchSet: 4 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Maor Lipchuk <mlipc...@redhat.com> Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com> Gerrit-Reviewer: Daniel Erez <de...@redhat.com> Gerrit-Reviewer: Liron Aravot <lara...@redhat.com> Gerrit-Reviewer: Maor Lipchuk <mlipc...@redhat.com> Gerrit-Reviewer: automat...@ovirt.org Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches