Details

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

      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()

        Gliffy Diagrams

          Activity

          Hide
          vineet.reynolds 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 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
          alrubinger Andrew Rubinger added a comment - Upstream: https://github.com/shrinkwrap/shrinkwrap/commit/0198e8cbbe7bcd8e7379c629f640b914c67deb95
          Hide
          mmatloka Michal Matloka added a comment - - edited

          With this we omit empty directories in copy ?

          Show
          mmatloka Michal Matloka added a comment - - edited With this we omit empty directories in copy ?
          Hide
          vineet.reynolds 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 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
          mmatloka 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
          mmatloka 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 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 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 Vineet Reynolds
              Reporter:
              mmatloka Michal Matloka
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development