exceptionfactory commented on code in PR #9122:
URL: https://github.com/apache/nifi/pull/9122#discussion_r1711601852


##########
nifi-extension-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/UnpackContent.java:
##########
@@ -470,22 +500,47 @@ protected boolean isFileEntryMatched(final boolean 
directory, final String fileN
                 return !directory && (fileFilter == null || 
fileFilter.matcher(fileName).find());
             }
 
-            protected void processEntry(final InputStream zipInputStream, 
final boolean directory, final String zipEntryName, final EncryptionMethod 
encryptionMethod) {
-                if (isFileEntryMatched(directory, zipEntryName)) {
-                    final File file = new File(zipEntryName);
+            protected void processEntry(final InputStream zipInputStream, 
ZipInputStreamMetadata metadata) {
+                if (isFileEntryMatched(metadata.directory(), 
metadata.zipEntryName())) {
+                    final File file = new File(metadata.zipEntryName());
                     final String parentDirectory = (file.getParent() == null) 
? PATH_SEPARATOR : file.getParent();
 
                     FlowFile unpackedFile = session.create(sourceFlowFile);
                     try {
-                        unpackedFile = session.putAllAttributes(unpackedFile, 
Map.of(
-                                CoreAttributes.FILENAME.key(), file.getName(),
-                                CoreAttributes.PATH.key(), parentDirectory,
-                                CoreAttributes.MIME_TYPE.key(), OCTET_STREAM,
-                                FILE_ENCRYPTION_METHOD_ATTRIBUTE, 
encryptionMethod.toString(),
-
-                                FRAGMENT_ID, fragmentId,
-                                FRAGMENT_INDEX, String.valueOf(++fragmentIndex)
-                        ));
+                        final Map<String, String> attributes = new HashMap<>();
+                        attributes.put(CoreAttributes.FILENAME.key(), 
file.getName());
+                        attributes.put(CoreAttributes.PATH.key(), 
parentDirectory);
+                        attributes.put(CoreAttributes.MIME_TYPE.key(), 
OCTET_STREAM);
+                        attributes.put(FILE_ENCRYPTION_METHOD_ATTRIBUTE, 
metadata.encryptionMethod().toString());
+                        attributes.put(FILE_SIZE_ATTRIBUTE, 
String.valueOf(metadata.uncompressedSize()));
+
+                        String timeAsString = null;

Review Comment:
   Reusing this variable makes the code difficult to follow. I recommend 
avoiding reuse and defining specific variables inside the conditional blocks as 
needed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to