@@ -77,32 +77,35 @@ public ObjectStorageSpaceVerificationResult objectsFromBucketWillFitInDirectory(
7777
7878 long requiredSpace = 0 ;
7979 long availableSpace = 0 ;
80- final IOException ioException = null ;
8180
8281 if ( ! pathObjectExists (destinationDirectory )) {
82+ final IOException ioException = null ;
8383 return new ObjectStorageSpaceVerificationResult (ObjectStorageSpaceVerificationResult .VerificationStatus .PathDoesNotExist ,
8484 requiredSpace , availableSpace , ioException );
8585 }
8686
8787 if ( ! pathIsDirectory (destinationDirectory )) {
88+ final IOException ioException = null ;
8889 return new ObjectStorageSpaceVerificationResult (ObjectStorageSpaceVerificationResult .VerificationStatus .PathIsNotADirectory ,
8990 requiredSpace , availableSpace , ioException );
9091 }
9192
9293 if ( ! pathIsWritable (destinationDirectory )) {
94+ final IOException ioException = null ;
9395 return new ObjectStorageSpaceVerificationResult (ObjectStorageSpaceVerificationResult .VerificationStatus .PathLacksAccess ,
9496 requiredSpace , availableSpace , ioException );
9597 }
9698
9799 try {
98100 helpers .ensureBucketExists (bucketName );
99101 } catch (final IOException e ) {
102+ final IOException ioException = null ;
100103 return new ObjectStorageSpaceVerificationResult (ObjectStorageSpaceVerificationResult .VerificationStatus .BucketDoesNotExist ,
101104 requiredSpace , availableSpace , ioException );
102105 }
103106
104107 try {
105- requiredSpace = getRequiredSpaceForObjects (getObjectSizes ( helpers , bucketName , objectNames ) );
108+ requiredSpace = getRequiredSpaceForObjects (helpers , bucketName , objectNames );
106109 availableSpace = getAvailableFileSpace (destinationDirectory );
107110 } catch (final IOException e ) {
108111 return new ObjectStorageSpaceVerificationResult (ObjectStorageSpaceVerificationResult .VerificationStatus .CaughtIOException ,
@@ -112,14 +115,17 @@ public ObjectStorageSpaceVerificationResult objectsFromBucketWillFitInDirectory(
112115 final ObjectStorageSpaceVerificationResult .VerificationStatus verificationStatus = availableSpace > requiredSpace ?
113116 ObjectStorageSpaceVerificationResult .VerificationStatus .OK : ObjectStorageSpaceVerificationResult .VerificationStatus .PathLacksSufficientStorageSpace ;
114117
118+ final IOException ioException = null ;
115119 return new ObjectStorageSpaceVerificationResult (verificationStatus , requiredSpace , availableSpace , ioException );
116120 }
117121
118- private Map < String , Long > getObjectSizes (final Ds3ClientHelpers helpers ,
119- final String bucketName ,
120- final Collection <String > objectNames )
121- throws IOException
122+ private long getRequiredSpaceForObjects (final Ds3ClientHelpers helpers ,
123+ final String bucketName ,
124+ final Collection <String > objectNames )
125+ throws IOException
122126 {
127+ long result = 0 ;
128+
123129 final Map <String , Long > objectSizeMap = new HashMap <>();
124130
125131 final Iterable <Contents > bucketContents = helpers .listObjects (bucketName );
@@ -128,14 +134,9 @@ private Map<String, Long> getObjectSizes(final Ds3ClientHelpers helpers,
128134 objectSizeMap .put (bucketContent .getKey (), bucketContent .getSize ());
129135 }
130136
137+ // Of the objects in the bucket, keep the information about only those in objectNames
131138 objectSizeMap .keySet ().retainAll (objectNames );
132139
133- return objectSizeMap ;
134- }
135-
136- private long getRequiredSpaceForObjects (final Map <String , Long > objectSizeMap ) {
137- long result = 0 ;
138-
139140 for (final long objectSize : objectSizeMap .values ()) {
140141 result += objectSize ;
141142 }
0 commit comments