[ https://issues.apache.org/jira/browse/CLOUDSTACK-9423?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15353213#comment-15353213 ]
ASF GitHub Bot commented on CLOUDSTACK-9423: -------------------------------------------- Github user swill commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1598#discussion_r68779423 --- Diff: core/src/com/cloud/storage/template/VhdProcessor.java --- @@ -91,27 +97,58 @@ public long getVirtualSize(File file) throws IOException { return file.length(); } - protected long getTemplateVirtualSize(File file) throws IOException { + protected long getTemplateVirtualSize(File file) throws IOException { byte[] currentSize = new byte[8]; + byte[] cookie = new byte[8]; byte[] creatorApp = new byte[4]; - try (FileInputStream strm = new FileInputStream(file)) { - long skipped = strm.skip(file.length() - vhdFooterSize + vhdFooterCreatorAppOffset); + + BufferedInputStream fileStream = new BufferedInputStream(new FileInputStream(file)); + InputStream strm = fileStream; + + boolean isCompressed = checkCompressed(file.getAbsolutePath()); + + if ( isCompressed ) { + try { + strm = new CompressorStreamFactory().createCompressorInputStream(fileStream); + } catch (CompressorException e) { + s_logger.info("error opening compressed VHD file " + file.getName()); + return file.length(); + } + } + + try { + --- End diff -- Can you remove the unneeded line break here since I already have another change for you to make. :) Thx... > Object storage should get the correct size for compressed templates > ------------------------------------------------------------------- > > Key: CLOUDSTACK-9423 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9423 > Project: CloudStack > Issue Type: Bug > Security Level: Public(Anyone can view this level - this is the > default.) > Reporter: syed ahmed > Labels: secondary_storage, swift, template > > When uploading templates to an object store like Swift, if the template is > compressed, we get an invalid size (negative). This fix tries to see if the > template is compressed, if so, gets the correct size by partially > decompressing the VHD header. -- This message was sent by Atlassian JIRA (v6.3.4#6332)