[jira] [Commented] (OFBIZ-10188) Add new FileUtil methods for zip management

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (OFBIZ-10188) Add new FileUtil methods for zip management

Nicolas Malin (Jira)

    [ https://issues.apache.org/jira/browse/OFBIZ-10188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16345317#comment-16345317 ]

Jacques Le Roux commented on OFBIZ-10188:
-----------------------------------------

Hi Gil,

I just had a quick look, it looks good to me.

Few remarks :

*FileUtilTests.groovy*
    Formatting
        in Groovy
        {code}
            while((len=zipStream.read(buf))>0){
        {code}
        OK in Java there:
        {code}
            while ((len = fileStream.read(bufferData)) > 0) {
         {code}
        Please check other places in Java (saw one at least)

    I guess it's OK to not handle exceptions and we suppose it will be handled by the caller?
    https://mrhaki.blogspot.fr/2009/09/groovy-goodness-exception-handling.html

    Else I guess this can use try-with-resource
    {code}
        +        //write it down into tmp folder
        +        OutputStream out = new FileOutputStream(readmeZipped)
        +        byte[] buf = new byte[1024]
        +        int len
        +        while((len=zipStream.read(buf))>0){
        +            out.write(buf,0,len)
        +        }
        +        out.close()
        +        zipStream.close()
        {code}

But be sure to check https://stackoverflow.com/questions/28636416/why-do-i-have-to-close-the-zipoutputstream-in-a-certain-way-in-this-situation

*FileUtil.java*

    Notsure if this can use try-with-resource, at least the order must be important
    {code}
    +        zos.closeEntry();
    +        zos.close();
    +        fos.close();
    {code}

    And alike in unzipFileToFolder()

HTH

> Add new FileUtil methods for zip management
> -------------------------------------------
>
>                 Key: OFBIZ-10188
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-10188
>             Project: OFBiz
>          Issue Type: New Feature
>            Reporter: Gil Portenseigne
>            Assignee: Gil Portenseigne
>            Priority: Minor
>             Fix For: Upcoming Branch
>
>         Attachments: OFBIZ-10188.patch
>
>
> Add new FileUtil methods for zip management.
> Add zipFileStream method that will zip FileStream to a zipped one.
> Add unzipFileToFolder method to unzip a given archive to a given Folder



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)