@@ -60,18 +60,6 @@ public interface ArchiveListener {
6060 boolean continueCreating (long bytesCopied , long bytesTotal );
6161 }
6262
63- /**
64- * Allows our recursive file copy operations to exclude files that we do not want in the archive.
65- */
66- private interface PathFilter {
67- /**
68- * Check whether something belongs in the archive
69- * @param path the file that will potentially be copied
70- * @return {@code true} to actually copy the file.
71- */
72- boolean include (Path path );
73- }
74-
7563 /**
7664 * Creates an archive file containing all the metadata found in the rekordbox media export containing the
7765 * supplied database export that is needed to enable full Beat Link features when that media is being used in
@@ -83,21 +71,20 @@ private interface PathFilter {
8371 * @throws IOException if there is a problem creating the archive
8472 */
8573 @ API (status = API .Status .EXPERIMENTAL )
86- public void createArchive (Database database , File file ) throws IOException {
74+ public void createArchive (final Database database , final File file ) throws IOException {
8775 createArchive (database , file , null );
8876 }
8977
9078 /**
9179 * Helper method to recursively count the number of file bytes that will be copied if we copy a folder.
9280 *
9381 * @param source the folder to be copied
94- * @param filter if present, allows files to be selectively excluded from being counted
9582 *
9683 * @return the new total number of bytes that need to be copied.
9784 *
9885 * @throws IOException if there is a problem scanning the folder
9986 */
100- private long sizeFolder (Path source , PathFilter filter )
87+ private long sizeFolder (final Path source )
10188 throws IOException {
10289
10390 final AtomicLong totalBytes = new AtomicLong (0 );
@@ -106,9 +93,7 @@ private long sizeFolder(Path source, PathFilter filter)
10693
10794 public FileVisitResult visitFile (Path file , BasicFileAttributes attrs )
10895 throws IOException {
109- if (filter == null || filter .include (file )) {
110- totalBytes .addAndGet (Files .size (file ));
111- }
96+ totalBytes .addAndGet (Files .size (file ));
11297 return FileVisitResult .CONTINUE ;
11398 }
11499 });
@@ -119,20 +104,19 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
119104 /**
120105 * Helper method to recursively copy a folder.
121106 *
122- * @param source the folder to be copied
123- * @param target where the folder should be copied
124- * @param filter if present, allows files to be selectively excluded from being counted
125- * @param listener if not {@code null} will be called after copying each file to support progress reports and
126- * allow cancellation
107+ * @param source the folder to be copied
108+ * @param target where the folder should be copied
109+ * @param listener if not {@code null} will be called after copying each file to support progress reports and
110+ * allow cancellation
127111 * @param bytesCopied the number of bytes that have already been copied, for use in updating the listener
128- * @param totalBytes the total number of bytes that are going to be copied, for use in updating the listener
129- * @param options the copy options (see {@link Files#copy(Path, Path, CopyOption...)})
112+ * @param totalBytes the total number of bytes that are going to be copied, for use in updating the listener
113+ * @param options the copy options (see {@link Files#copy(Path, Path, CopyOption...)})
130114 *
131115 * @return the new total number of bytes copied, or -1 if the listener requested that the copy be canceled.
132116 *
133117 * @throws IOException if there is a problem copying the folder
134118 */
135- private long copyFolder (Path source , Path target , PathFilter filter , ArchiveListener listener , long bytesCopied , long totalBytes , CopyOption ... options )
119+ private long copyFolder (final Path source , final Path target , final ArchiveListener listener , final long bytesCopied , final long totalBytes , final CopyOption ... options )
136120 throws IOException {
137121
138122 final AtomicLong nowCopied = new AtomicLong (bytesCopied );
@@ -148,17 +132,14 @@ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
148132
149133 public FileVisitResult visitFile (Path file , BasicFileAttributes attrs )
150134 throws IOException {
151- if (filter == null || filter .include (file )) {
152- Files .copy (file , target .resolve (source .relativize (file ).toString ()), options );
153- nowCopied .addAndGet (Files .size (file ));
154- if (listener == null || listener .continueCreating (nowCopied .get (), totalBytes )) {
155- return FileVisitResult .CONTINUE ;
156- } else {
157- canceled .set (true );
158- return FileVisitResult .TERMINATE ;
159- }
135+ Files .copy (file , target .resolve (source .relativize (file ).toString ()), options );
136+ nowCopied .addAndGet (Files .size (file ));
137+ if (listener == null || listener .continueCreating (nowCopied .get (), totalBytes )) {
138+ return FileVisitResult .CONTINUE ;
139+ } else {
140+ canceled .set (true );
141+ return FileVisitResult .TERMINATE ;
160142 }
161- return FileVisitResult .CONTINUE ;
162143 }
163144 });
164145
@@ -181,12 +162,10 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
181162 * @throws IOException if there is a problem creating the archive
182163 */
183164 @ API (status = API .Status .EXPERIMENTAL )
184- public void createArchive (Database database , File archiveFile , ArchiveListener listener ) throws IOException {
165+ public void createArchive (final Database database , final File archiveFile , final ArchiveListener listener ) throws IOException {
185166 final Path archivePath = archiveFile .toPath ();
186167 Files .deleteIfExists (archivePath );
187168 final URI fileUri = archivePath .toUri ();
188- // We want to exclude .2EX files since we can’t use them, and they bloat the archive.
189- final PathFilter analysisFilter = path -> !path .toString ().endsWith (".2EX" );
190169 boolean failed = false ;
191170
192171 try (FileSystem fileSystem = FileSystems .newFileSystem (new URI ("jar:" + fileUri .getScheme (), fileUri .getPath (), null ),
@@ -207,15 +186,15 @@ public void createArchive(Database database, File archiveFile, ArchiveListener l
207186 final Path artFolder = pioneerFolder .resolve ("Artwork" );
208187 //noinspection SpellCheckingInspection
209188 final Path analysisFolder = pioneerFolder .resolve ("USBANLZ" );
210- final long totalBytes = sizeFolder (artFolder , null ) + sizeFolder (analysisFolder , analysisFilter );
211- long bytesCopied = copyFolder (artFolder , fileSystem .getPath (pioneerFolderName , "Artwork" ), null , listener ,
189+ final long totalBytes = sizeFolder (artFolder ) + sizeFolder (analysisFolder );
190+ long bytesCopied = copyFolder (artFolder , fileSystem .getPath (pioneerFolderName , "Artwork" ), listener ,
212191 0 , totalBytes , StandardCopyOption .REPLACE_EXISTING );
213192 if (bytesCopied < 0 ) {
214193 // Listener asked us to cancel.
215194 failed = true ;
216195 } else {
217196 //noinspection SpellCheckingInspection
218- bytesCopied = copyFolder (analysisFolder , fileSystem .getPath (pioneerFolderName , "USBANLZ" ), analysisFilter , listener ,
197+ bytesCopied = copyFolder (analysisFolder , fileSystem .getPath (pioneerFolderName , "USBANLZ" ), listener ,
219198 bytesCopied , totalBytes , StandardCopyOption .REPLACE_EXISTING );
220199 if (bytesCopied < 0 ) {
221200 failed = true ;
0 commit comments