Details

    • Type: Bug Bug
    • Status: Closed Closed (View Workflow)
    • Priority: Major Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: 1.1.1
    • Component/s: None
    • Labels:
    • Steps to Reproduce:
      Hide

      1. Create archive, e.g. from zip
      2. execute shallowCopy() method

      Show
      1. Create archive, e.g. from zip 2. execute shallowCopy() method
    • Similar Issues:
      Show 7 results 

      Description

      When archive contains directories, shallow copy throws exception due to

       for (final ArchivePath path : contents.keySet()) {
           newArchive.add(contents.get(path).getAsset(), path);
       }
      

      because add(...) checks

      Validate.notNull(asset, "No asset was specified");
      

      it is possible that same bug concerns also ArchiveBase.shallowCopy()

        Activity

        Hide
        Vineet Reynolds
        added a comment -

        ArchiveBase.shallowCopy() and ContainerBase.shallowCopy() now copies over pointers if there is an asset associated with the path. If no asset is available in the specified path, the path is omitted from the copy. This assumes the presence of an asset in a nested path.

        Show
        Vineet Reynolds
        added a comment - ArchiveBase.shallowCopy() and ContainerBase.shallowCopy() now copies over pointers if there is an asset associated with the path. If no asset is available in the specified path, the path is omitted from the copy. This assumes the presence of an asset in a nested path.
        Show
        Andrew Rubinger
        added a comment - Upstream: https://github.com/shrinkwrap/shrinkwrap/commit/0198e8cbbe7bcd8e7379c629f640b914c67deb95
        Hide
        Michal Matloka
        added a comment - - edited

        With this we omit empty directories in copy ?

        Show
        Michal Matloka
        added a comment - - edited With this we omit empty directories in copy ?
        Hide
        Vineet Reynolds
        added a comment -

        Yes, that is right. Empty directories that have no nested assets are omitted in the shallow copy.

        If you have META-INF/services/foo in the archive where foo is an Asset (could be an EmptyAsset), then a shallow copy will have the same structure. But if you have META-INF/ then a shallow copy will omit the META-INF/ directory.

        Show
        Vineet Reynolds
        added a comment - Yes, that is right. Empty directories that have no nested assets are omitted in the shallow copy. If you have META-INF/services/foo in the archive where foo is an Asset (could be an EmptyAsset ), then a shallow copy will have the same structure. But if you have META-INF/ then a shallow copy will omit the META-INF/ directory.
        Hide
        Michal Matloka
        added a comment -

        I am wondering is this the most intuitive approach for the user. e.g. I would expect, that after doing shallow copy I would receive exactly the same structure - in this case containing those empty directories.

        Show
        Michal Matloka
        added a comment - I am wondering is this the most intuitive approach for the user. e.g. I would expect, that after doing shallow copy I would receive exactly the same structure - in this case containing those empty directories.
        Hide
        Vineet Reynolds
        added a comment -

        Well, it appears easy to resolve that. I've tested modified my original change locally, from:

        if (asset != null) {
          to.add(asset, path);
        }
        

        to:

        if (asset != null) {
          to.add(asset, path);
        } else {
          to.addAsDirectory(path);
        }
        

        This retains the original directories, but I'm not sure if this (use of addAsDirectory) obeys all the semantics expected of shallowCopy(). I'll investigate this more closely.

        Show
        Vineet Reynolds
        added a comment - Well, it appears easy to resolve that. I've tested modified my original change locally, from: if (asset != null ) { to.add(asset, path); } to: if (asset != null ) { to.add(asset, path); } else { to.addAsDirectory(path); } This retains the original directories, but I'm not sure if this (use of addAsDirectory ) obeys all the semantics expected of shallowCopy() . I'll investigate this more closely.

          People

          • Assignee:
            Vineet Reynolds
            Reporter:
            Michal Matloka
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: