Plexus-Archiver: Understanding the logic of AbstractZipArchiver.createArchiveMain()

View: New views
3 Messages — Rating Filter:   Alert me  

Plexus-Archiver: Understanding the logic of AbstractZipArchiver.createArchiveMain()

by Jochen Wiedmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

the method AbstractZipArchiver.createArchiveMain() looks roughly like this:

    private void createArchiveMain()
        throws ArchiverException, IOException
    {
        zipFile = getDestFile();
        ...
        if ( doUpdate )
        {
            renamedFile = FileUtils.createTempFile( "zip", ".tmp",
zipFile.getParentFile() );
            renamedFile.deleteOnExit();
            ...
            FileUtils.rename( zipFile, renamedFile );
            ...
        }

        ...
        // Add the new files to the archive.
        addResources( getResourcesToAdd( zipFile ), zOut );

        if ( doUpdate )
        {
            addResources( getResourcesToUpdate( zipFile ), zOut );
        }
    }


In other words: If getResourcesToUpdate( zipFile ) is invoked, then
the file zipFile is guaranteed not to exist. Likewise, if
getResourcesToAdd( zipFile ) is invoked, then either the file does not
exist, or doUpdate is false.

Again, in other words: The method getResourcesToAdd( zipFile ) will
always return all the files. And the method getResourcesToUpdate will
always return no files at all.

Conclusion: Update is guaranteed not to work.


Am I missing something?


Thanks,

Jochen



--
Look, that's why there's rules, understand? So that you think before
you break 'em.

    -- (Terry Pratchett, Thief of Time)

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email


Re: Plexus-Archiver: Understanding the logic of AbstractZipArchiver.createArchiveMain()

by Jochen Wiedmann :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


[Reposting in hope for a response.]

Hi,

the method AbstractZipArchiver.createArchiveMain() looks roughly like this:

    private void createArchiveMain()
        throws ArchiverException, IOException
    {
        zipFile = getDestFile();
        ...
        if ( doUpdate )
        {
            renamedFile = FileUtils.createTempFile( "zip", ".tmp",
zipFile.getParentFile() );
            renamedFile.deleteOnExit();
            ...
            FileUtils.rename( zipFile, renamedFile );
            ...
        }

        ...
        // Add the new files to the archive.
        addResources( getResourcesToAdd( zipFile ), zOut );

        if ( doUpdate )
        {
            addResources( getResourcesToUpdate( zipFile ), zOut );
        }
    }


In other words: If getResourcesToUpdate( zipFile ) is invoked, then
the file zipFile is guaranteed not to exist. Likewise, if
getResourcesToAdd( zipFile ) is invoked, then either the file does not
exist, or doUpdate is false.

Again, in other words: The method getResourcesToAdd( zipFile ) will
always return all the files. And the method getResourcesToUpdate will
always return no files at all.

Conclusion: Update is guaranteed not to work.


Am I missing something?


Thanks,

Jochen



--
Look, that's why there's rules, understand? So that you think before
you break 'em.

    -- (Terry Pratchett, Thief of Time)

Re: Plexus-Archiver: Understanding the logic of AbstractZipArchiver.createArchiveMain()

by Jason van Zyl-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Probably not, just fix it as you see fit.

On 6-Jan-08, at 1:04 PM, Jochen Wiedmann wrote:

> Hi,
>
> the method AbstractZipArchiver.createArchiveMain() looks roughly  
> like this:
>
>    private void createArchiveMain()
>        throws ArchiverException, IOException
>    {
>        zipFile = getDestFile();
>        ...
>        if ( doUpdate )
>        {
>            renamedFile = FileUtils.createTempFile( "zip", ".tmp",
> zipFile.getParentFile() );
>            renamedFile.deleteOnExit();
>            ...
>            FileUtils.rename( zipFile, renamedFile );
>            ...
>        }
>
>        ...
>        // Add the new files to the archive.
>        addResources( getResourcesToAdd( zipFile ), zOut );
>
>        if ( doUpdate )
>        {
>            addResources( getResourcesToUpdate( zipFile ), zOut );
>        }
>    }
>
>
> In other words: If getResourcesToUpdate( zipFile ) is invoked, then
> the file zipFile is guaranteed not to exist. Likewise, if
> getResourcesToAdd( zipFile ) is invoked, then either the file does not
> exist, or doUpdate is false.
>
> Again, in other words: The method getResourcesToAdd( zipFile ) will
> always return all the files. And the method getResourcesToUpdate will
> always return no files at all.
>
> Conclusion: Update is guaranteed not to work.
>
>
> Am I missing something?
>
>
> Thanks,
>
> Jochen
>
>
>
> --
> Look, that's why there's rules, understand? So that you think before
> you break 'em.
>
>    -- (Terry Pratchett, Thief of Time)
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>    http://xircles.codehaus.org/manage_email
>

Thanks,

Jason

----------------------------------------------------------
Jason van Zyl
Founder,  Apache Maven
jason at sonatype dot com
----------------------------------------------------------

Our achievements speak for themselves. What we have to keep track
of are our failures, discouragements and doubts. We tend to forget
the past difficulties, the many false starts, and the painful
groping. We see our past achievements as the end result of a
clean forward thrust, and our present difficulties as
signs of decline and decay.

-- Eric Hoffer, Reflections on the Human Condition




---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email