<fim-prefix>tArchive, rows);
				}
			} catch (IOException e) {
				logError("", e);
			}
		}
	}
	
	private void copyUploadFile(BulkAssessmentDatas datas, File uploadedFile, List<BulkAssessmentRow> rows) throws IOException {
		try(FileInputStream inStream = new FileInputStream(uploadedFile)) {
			if(VFSManager.copyContent(inStream, targetArchive)) {
				datas.setReturnFiles(targetArchive.getRelPath());
				processReturnFiles(targetArchive, rows);
			}
		} catch(IOException e) {
			logError("", e);
			throw e;
		}
	}

	private boolean isSame(VFSItem currentTarget, File uploadedFile) {
		if(currentTarget instanceof LocalImpl) {
			LocalImpl local = (LocalImpl)currentTarget;
			File currentFile = local.getBasefile();
			if(currentFile.length() == uploadedFile.length()) {
				try {
					return org.apache.commons.io.FileUtils.contentEquals(currentFile, uploadedFile);
				} catch (IOException e) {
					logError("", e);
					//do nothing -> return false at the end
				}
			}
		}
		return false;
	}

	private void processReturnFiles(VFSLeaf target, List<BulkAssessmentRow> rows) {
		Map<String, BulkAssessmentRow> assessedIdToRow = new HashMap<>();
		for(BulkAssessmentRow row:rows) {
			assessedIdToRow.put(row.getAssessedId(), row);
		}

		if(target.exists()) {
			File parentTarget = ((LocalImpl)target).getBasefile().getParentFile();

			ZipEntry entry;
			try(InputStream is = target.getInputStream();
					ZipInputStream zis = new ZipInputStream(is)) {
				byte[] b = new byte[FileUtils.BSIZE];
				// BUG: CWE-22 Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
				// while ((entry = zis.getNextEntry()) != null) {
				// FIXED:
	<fim-middle>			while ((entry = zis.getNextEntry()) != null) {//TODO zip
					if(!entry.isDirectory()) {
						while (zis.read(b) > 0) {
							//continue
						}

						Path op = new File(parentTarget, entry.getNa<fix-suffix>me()).toPath();
						if(!Files.isHidden(op) && !op.toFile().isDirectory()) {
							Path parentDir = op.getParent();
							String assessedId = parentDir.getFileName().toString();
							String filename = op.getFileName().toString();

							BulkAssessmentRow row;
							if(assessedIdToRow.containsKey(assessedId)) {
								row = assessedIdToRow.get(assessedId);
							} else {
								row = new BulkAssessmentRow();
								row.setAssessedId(assessedId);
								assessedIdToRow.put(assessedId, row);
								rows.add(row);
							}

							if(row.getReturnFiles() == null) {
								row.setReturnFiles(new ArrayList<String>(2));
							}
							row.getReturnFiles().add(filename);
						}
					}
				}
			} catch(Exception e) {
				logError("", e);
			}
		}
	}
}<|endoftext|>