From 0ad2d9e721d1fa6b1d837f07adea7572e8b48576 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Fri, 5 Jan 2024 11:11:18 +0600 Subject: [PATCH 1/4] 1712-Ignore_part_file_sync issue: https://gitlab.e.foundation/e/os/backlog/-/issues/1712 --- .../e/drive/fileFilters/AppSettingsFileFilter.java | 9 ++++++--- .../e/drive/fileFilters/CrashlogsFileFilter.java | 5 +++++ .../foundation/e/drive/fileFilters/MediaFileFilter.java | 8 +++++--- .../e/drive/fileFilters/NoCacheFileFilter.java | 5 ++++- .../foundation/e/drive/fileFilters/OnlyFileFilter.java | 4 +++- .../foundation/e/drive/fileObservers/FileEventHandler.kt | 5 +++++ .../e/drive/fileObservers/FileObserverManager.kt | 3 ++- app/src/main/java/foundation/e/drive/utils/FileUtils.kt | 3 +++ 8 files changed, 33 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/fileFilters/AppSettingsFileFilter.java b/app/src/main/java/foundation/e/drive/fileFilters/AppSettingsFileFilter.java index 956efe44..26e422ed 100644 --- a/app/src/main/java/foundation/e/drive/fileFilters/AppSettingsFileFilter.java +++ b/app/src/main/java/foundation/e/drive/fileFilters/AppSettingsFileFilter.java @@ -13,6 +13,8 @@ import java.io.File; import java.io.FileFilter; import java.util.Locale; +import foundation.e.drive.utils.FileUtils; + /** * @author Vincent Bourgmayer * FileFilter for application Settings @@ -20,8 +22,9 @@ import java.util.Locale; class AppSettingsFileFilter implements FileFilter { @Override public boolean accept(File pathname) { - return pathname.isFile() - || (pathname.isDirectory() - && !pathname.getName().toLowerCase(Locale.ROOT).contains("cache")); + return FileUtils.isNotPartFile(pathname) + && (pathname.isFile() + || (pathname.isDirectory() + && !pathname.getName().toLowerCase(Locale.ROOT).contains("cache"))); } } diff --git a/app/src/main/java/foundation/e/drive/fileFilters/CrashlogsFileFilter.java b/app/src/main/java/foundation/e/drive/fileFilters/CrashlogsFileFilter.java index 6f28fddc..c1d7f3cb 100644 --- a/app/src/main/java/foundation/e/drive/fileFilters/CrashlogsFileFilter.java +++ b/app/src/main/java/foundation/e/drive/fileFilters/CrashlogsFileFilter.java @@ -14,6 +14,7 @@ import androidx.annotation.NonNull; import java.io.File; import java.io.FileFilter; +import foundation.e.drive.utils.FileUtils; import foundation.e.drive.utils.ServiceExceptionHandler; /** @@ -24,6 +25,10 @@ public class CrashlogsFileFilter implements FileFilter { @Override public boolean accept(@NonNull File pathname) { + if (!FileUtils.isNotPartFile(pathname)) { + return false; + } + String fileTimestamp = extractTimestamp(pathname.getName(), ServiceExceptionHandler.LOG_FILE_NAME_PREFIX, ServiceExceptionHandler.LOG_FILE_EXTENSION); diff --git a/app/src/main/java/foundation/e/drive/fileFilters/MediaFileFilter.java b/app/src/main/java/foundation/e/drive/fileFilters/MediaFileFilter.java index 6ac1740a..1c67e869 100644 --- a/app/src/main/java/foundation/e/drive/fileFilters/MediaFileFilter.java +++ b/app/src/main/java/foundation/e/drive/fileFilters/MediaFileFilter.java @@ -12,18 +12,20 @@ package foundation.e.drive.fileFilters; import java.io.File; import java.io.FileFilter; +import foundation.e.drive.utils.FileUtils; + /** * @author Vincent Bourgmayer */ class MediaFileFilter implements FileFilter { /** - * Only accept not hidden files: - * Media should not be synced if they're hidden files + * Only accept not hidden files & not .part files + * Media should not be synced if they're hidden files or .part files * @param file File to check * @return true if file is accepted */ @Override public boolean accept(File file) { - return !file.isHidden(); + return !file.isHidden() && FileUtils.isNotPartFile(file); } } diff --git a/app/src/main/java/foundation/e/drive/fileFilters/NoCacheFileFilter.java b/app/src/main/java/foundation/e/drive/fileFilters/NoCacheFileFilter.java index 075f7d92..18972e98 100644 --- a/app/src/main/java/foundation/e/drive/fileFilters/NoCacheFileFilter.java +++ b/app/src/main/java/foundation/e/drive/fileFilters/NoCacheFileFilter.java @@ -11,12 +11,15 @@ import java.io.File; import java.io.FileFilter; import java.util.Locale; +import foundation.e.drive.utils.FileUtils; + /** * @author Vincent Bourgmayer */ class NoCacheFileFilter implements FileFilter { @Override public boolean accept(File pathname) { - return ( ! pathname.getName().toLowerCase(Locale.ROOT).contains("cache") ); + return (!pathname.getName().toLowerCase(Locale.ROOT).contains("cache") + && FileUtils.isNotPartFile(pathname)); } } diff --git a/app/src/main/java/foundation/e/drive/fileFilters/OnlyFileFilter.java b/app/src/main/java/foundation/e/drive/fileFilters/OnlyFileFilter.java index a5b4b32d..8f4360aa 100644 --- a/app/src/main/java/foundation/e/drive/fileFilters/OnlyFileFilter.java +++ b/app/src/main/java/foundation/e/drive/fileFilters/OnlyFileFilter.java @@ -14,12 +14,14 @@ import androidx.annotation.NonNull; import java.io.File; import java.io.FileFilter; +import foundation.e.drive.utils.FileUtils; + /** * @author Vincent Bourgmayer */ public class OnlyFileFilter implements FileFilter { @Override public boolean accept(@NonNull File pathname) { - return (!pathname.isDirectory()); + return (!pathname.isDirectory() && FileUtils.isNotPartFile(pathname)); } } diff --git a/app/src/main/java/foundation/e/drive/fileObservers/FileEventHandler.kt b/app/src/main/java/foundation/e/drive/fileObservers/FileEventHandler.kt index e93ea972..144f05ac 100644 --- a/app/src/main/java/foundation/e/drive/fileObservers/FileEventHandler.kt +++ b/app/src/main/java/foundation/e/drive/fileObservers/FileEventHandler.kt @@ -20,6 +20,7 @@ import foundation.e.drive.models.SyncRequest import foundation.e.drive.models.SyncedFileState import foundation.e.drive.models.SyncedFolder import foundation.e.drive.synchronization.SyncProxy +import foundation.e.drive.utils.FileUtils import foundation.e.drive.utils.FileUtils.getLocalPath import timber.log.Timber import java.io.File @@ -32,6 +33,10 @@ import java.io.File class FileEventHandler(private val context: Context) { fun onEvent(event: Int, file: File) { + if (!FileUtils.isNotPartFile(file)) { + return + } + if (file.isDirectory) { handleDirectoryEvent(event, file) return diff --git a/app/src/main/java/foundation/e/drive/fileObservers/FileObserverManager.kt b/app/src/main/java/foundation/e/drive/fileObservers/FileObserverManager.kt index 39bb91fa..5a7e6870 100644 --- a/app/src/main/java/foundation/e/drive/fileObservers/FileObserverManager.kt +++ b/app/src/main/java/foundation/e/drive/fileObservers/FileObserverManager.kt @@ -14,6 +14,7 @@ import android.os.Build import android.os.FileObserver import foundation.e.drive.database.DbHelper import foundation.e.drive.models.SyncedFolder +import foundation.e.drive.utils.FileUtils import timber.log.Timber import java.io.File import java.io.FileFilter @@ -28,7 +29,7 @@ class FileObserverManager(private val context: Context) : FileEventListener { companion object { val WATCHABLE_DIRECTORIES_FILTER = FileFilter { - it.isDirectory && !it.isHidden + it.isDirectory && !it.isHidden && FileUtils.isNotPartFile(it) } } diff --git a/app/src/main/java/foundation/e/drive/utils/FileUtils.kt b/app/src/main/java/foundation/e/drive/utils/FileUtils.kt index 77185ebd..774df298 100644 --- a/app/src/main/java/foundation/e/drive/utils/FileUtils.kt +++ b/app/src/main/java/foundation/e/drive/utils/FileUtils.kt @@ -66,4 +66,7 @@ object FileUtils { return "*/*" } } + + @JvmStatic + fun isNotPartFile(file: File) = !file.name.endsWith(".part") } \ No newline at end of file -- GitLab From bc54ea8190c959439ea6e96dc38289ab68d9f653 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Mon, 8 Jan 2024 19:41:41 +0600 Subject: [PATCH 2/4] improvement: Refactor FileFilter implementation Simplify the fileFilter implementation by removing non required classes, move the common checks to BasicFileFilter, re-write fileFilterFactory to kotlin, implement separate fileFilters as annonymous objects. issue: https://gitlab.e.foundation/e/os/backlog/-/issues/1712 --- .../fileFilters/AppSettingsFileFilter.java | 30 -------- .../fileFilters/CrashlogsFileFilter.java | 61 ---------------- .../drive/fileFilters/FileFilterFactory.java | 40 ---------- .../e/drive/fileFilters/FileFilterFactory.kt | 73 +++++++++++++++++++ .../e/drive/fileFilters/MediaFileFilter.java | 31 -------- .../drive/fileFilters/NoCacheFileFilter.java | 25 ------- .../e/drive/fileFilters/OnlyFileFilter.java | 27 ------- .../drive/fileFilters/SettingsFileFilter.java | 34 --------- .../contentScanner/LocalFileLister.java | 2 +- 9 files changed, 74 insertions(+), 249 deletions(-) delete mode 100644 app/src/main/java/foundation/e/drive/fileFilters/AppSettingsFileFilter.java delete mode 100644 app/src/main/java/foundation/e/drive/fileFilters/CrashlogsFileFilter.java delete mode 100644 app/src/main/java/foundation/e/drive/fileFilters/FileFilterFactory.java create mode 100644 app/src/main/java/foundation/e/drive/fileFilters/FileFilterFactory.kt delete mode 100644 app/src/main/java/foundation/e/drive/fileFilters/MediaFileFilter.java delete mode 100644 app/src/main/java/foundation/e/drive/fileFilters/NoCacheFileFilter.java delete mode 100644 app/src/main/java/foundation/e/drive/fileFilters/OnlyFileFilter.java delete mode 100644 app/src/main/java/foundation/e/drive/fileFilters/SettingsFileFilter.java diff --git a/app/src/main/java/foundation/e/drive/fileFilters/AppSettingsFileFilter.java b/app/src/main/java/foundation/e/drive/fileFilters/AppSettingsFileFilter.java deleted file mode 100644 index 26e422ed..00000000 --- a/app/src/main/java/foundation/e/drive/fileFilters/AppSettingsFileFilter.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright © CLEUS SAS 2018-2019. - * Copyright © ECORP SAS 2020. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - */ - -package foundation.e.drive.fileFilters; - -import java.io.File; -import java.io.FileFilter; -import java.util.Locale; - -import foundation.e.drive.utils.FileUtils; - -/** - * @author Vincent Bourgmayer - * FileFilter for application Settings - */ -class AppSettingsFileFilter implements FileFilter { - @Override - public boolean accept(File pathname) { - return FileUtils.isNotPartFile(pathname) - && (pathname.isFile() - || (pathname.isDirectory() - && !pathname.getName().toLowerCase(Locale.ROOT).contains("cache"))); - } -} diff --git a/app/src/main/java/foundation/e/drive/fileFilters/CrashlogsFileFilter.java b/app/src/main/java/foundation/e/drive/fileFilters/CrashlogsFileFilter.java deleted file mode 100644 index c1d7f3cb..00000000 --- a/app/src/main/java/foundation/e/drive/fileFilters/CrashlogsFileFilter.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright © CLEUS SAS 2018-2019. - * Copyright © ECORP SAS 2020. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - */ - -package foundation.e.drive.fileFilters; - -import androidx.annotation.NonNull; - -import java.io.File; -import java.io.FileFilter; - -import foundation.e.drive.utils.FileUtils; -import foundation.e.drive.utils.ServiceExceptionHandler; - -/** - * @Author Vincent Bourgmayer - */ -public class CrashlogsFileFilter implements FileFilter { - private final static long max_timestamp_delta = 864000000; //10 days in ms (240*3600*1000) - - @Override - public boolean accept(@NonNull File pathname) { - if (!FileUtils.isNotPartFile(pathname)) { - return false; - } - - String fileTimestamp = extractTimestamp(pathname.getName(), - ServiceExceptionHandler.LOG_FILE_NAME_PREFIX, - ServiceExceptionHandler.LOG_FILE_EXTENSION); - - long timestamp; - try { - timestamp = Long.parseLong(fileTimestamp); - }catch (NumberFormatException e){ - //Can't parse the extracted timestamp - //This file has not the expected name. It must be removed - return true; - } - - //if current Date - file date >= max deta allowed - return ((System.currentTimeMillis() - timestamp ) >= max_timestamp_delta); - } - - /** - * Extract the timestamp from the name of the file - * UnitTested! - * @param fileName Filename - * @param prefix prefix to ignore - * @param extension extension to ignore - * @return the timestamp extracted from the name - */ - private String extractTimestamp(String fileName, @NonNull String prefix, @NonNull String extension){ - return fileName.substring(prefix.length(), (fileName.length() - extension.length())); - } - -} \ No newline at end of file diff --git a/app/src/main/java/foundation/e/drive/fileFilters/FileFilterFactory.java b/app/src/main/java/foundation/e/drive/fileFilters/FileFilterFactory.java deleted file mode 100644 index f0153965..00000000 --- a/app/src/main/java/foundation/e/drive/fileFilters/FileFilterFactory.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright © CLEUS SAS 2018-2019. - * Copyright © ECORP SAS 2020. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - */ - -package foundation.e.drive.fileFilters; - -import androidx.annotation.NonNull; - -import java.io.FileFilter; - -/** - * @author Vincent Bourgmayer - */ -public class FileFilterFactory { - - @NonNull - public static FileFilter getFileFilter(@NonNull String category){ - FileFilter filter; - switch (category){ - case "Rom settings": - filter = new SettingsFileFilter(); - break; - case "Applications": - filter = new AppSettingsFileFilter(); - break; - case "media": - filter = new MediaFileFilter(); - break; - default: - filter = new NoCacheFileFilter(); - break; - } - return filter; - } -} diff --git a/app/src/main/java/foundation/e/drive/fileFilters/FileFilterFactory.kt b/app/src/main/java/foundation/e/drive/fileFilters/FileFilterFactory.kt new file mode 100644 index 00000000..0118c8c2 --- /dev/null +++ b/app/src/main/java/foundation/e/drive/fileFilters/FileFilterFactory.kt @@ -0,0 +1,73 @@ +/* + * Copyright MURENA SAS 2024 + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package foundation.e.drive.fileFilters; + +import foundation.e.drive.utils.AppConstants +import foundation.e.drive.utils.FileUtils +import java.io.File +import java.io.FileFilter + +/** + * @author Vincent Bourgmayer + * @author Fahim Salam Chowdhury + */ +object FileFilterFactory { + + fun buildFileFilter(category: String): FileFilter { + return when (category) { + "Rom settings" -> buildSettingsFilter() + "Applications" -> buildAppSettingsFilter() + "media" -> BasicFileFilter() + else -> buildNoCacheFileFilter() + } + } + + private fun buildSettingsFilter(): FileFilter { + return object : BasicFileFilter() { + override fun accept(pathname: File?): Boolean { + return super.accept(pathname) && pathname!!.isFile && + (pathname.name.startsWith("settings_") && pathname.name.endsWith(".xml") + || pathname.name == AppConstants.APPLICATIONS_LIST_FILE_NAME) + } + } + } + + private fun buildAppSettingsFilter(): FileFilter { + return object : BasicFileFilter() { + override fun accept(pathname: File?): Boolean { + return (super.accept(pathname) + && (pathname!!.isFile || (pathname.isDirectory + && !pathname.name.lowercase().contains("cache")))) + } + } + } + + private fun buildNoCacheFileFilter(): FileFilter { + return object : BasicFileFilter() { + override fun accept(pathname: File?): Boolean { + return super.accept(pathname) && + !pathname!!.name.lowercase().contains("cache") + } + } + } +} + +private open class BasicFileFilter : FileFilter { + override fun accept(pathname: File?): Boolean { + return pathname != null && !pathname.isHidden && FileUtils.isNotPartFile(pathname) + } +} diff --git a/app/src/main/java/foundation/e/drive/fileFilters/MediaFileFilter.java b/app/src/main/java/foundation/e/drive/fileFilters/MediaFileFilter.java deleted file mode 100644 index 1c67e869..00000000 --- a/app/src/main/java/foundation/e/drive/fileFilters/MediaFileFilter.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright © CLEUS SAS 2018-2019. - * Copyright © ECORP SAS 2020. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - */ - -package foundation.e.drive.fileFilters; - -import java.io.File; -import java.io.FileFilter; - -import foundation.e.drive.utils.FileUtils; - -/** - * @author Vincent Bourgmayer - */ -class MediaFileFilter implements FileFilter { - /** - * Only accept not hidden files & not .part files - * Media should not be synced if they're hidden files or .part files - * @param file File to check - * @return true if file is accepted - */ - @Override - public boolean accept(File file) { - return !file.isHidden() && FileUtils.isNotPartFile(file); - } -} diff --git a/app/src/main/java/foundation/e/drive/fileFilters/NoCacheFileFilter.java b/app/src/main/java/foundation/e/drive/fileFilters/NoCacheFileFilter.java deleted file mode 100644 index 18972e98..00000000 --- a/app/src/main/java/foundation/e/drive/fileFilters/NoCacheFileFilter.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright © CLEUS SAS 2018-2019. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - */ -package foundation.e.drive.fileFilters; - -import java.io.File; -import java.io.FileFilter; -import java.util.Locale; - -import foundation.e.drive.utils.FileUtils; - -/** - * @author Vincent Bourgmayer - */ -class NoCacheFileFilter implements FileFilter { - @Override - public boolean accept(File pathname) { - return (!pathname.getName().toLowerCase(Locale.ROOT).contains("cache") - && FileUtils.isNotPartFile(pathname)); - } -} diff --git a/app/src/main/java/foundation/e/drive/fileFilters/OnlyFileFilter.java b/app/src/main/java/foundation/e/drive/fileFilters/OnlyFileFilter.java deleted file mode 100644 index 8f4360aa..00000000 --- a/app/src/main/java/foundation/e/drive/fileFilters/OnlyFileFilter.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright © CLEUS SAS 2018-2019. - * Copyright © ECORP SAS 2020. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - */ - -package foundation.e.drive.fileFilters; - -import androidx.annotation.NonNull; - -import java.io.File; -import java.io.FileFilter; - -import foundation.e.drive.utils.FileUtils; - -/** - * @author Vincent Bourgmayer - */ -public class OnlyFileFilter implements FileFilter { - @Override - public boolean accept(@NonNull File pathname) { - return (!pathname.isDirectory() && FileUtils.isNotPartFile(pathname)); - } -} diff --git a/app/src/main/java/foundation/e/drive/fileFilters/SettingsFileFilter.java b/app/src/main/java/foundation/e/drive/fileFilters/SettingsFileFilter.java deleted file mode 100644 index 6c142079..00000000 --- a/app/src/main/java/foundation/e/drive/fileFilters/SettingsFileFilter.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright © CLEUS SAS 2018-2019. - * Copyright © ECORP SAS 2020. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the GNU Public License v3.0 - * which accompanies this distribution, and is available at - * http://www.gnu.org/licenses/gpl.html - */ - -package foundation.e.drive.fileFilters; - -import java.io.File; -import java.io.FileFilter; -import foundation.e.drive.utils.AppConstants; - -/** - * @author Vincent Bourgmayer - * @author Narinder Rana - * Filter for Device settings synchronisation - */ - class SettingsFileFilter implements FileFilter { - /** - * Only accept file with name beginning by "settings_" and ending with ".xml". - * @param pathName path to analyze - * @return True if accepted or false - */ - @Override - public boolean accept(File pathName) { - String name = pathName.getName(); - return ( pathName.isFile() && - ( ( name.startsWith("settings_") && name.endsWith(".xml") ) - || name.equals( AppConstants.APPLICATIONS_LIST_FILE_NAME ) ) ); - } -} diff --git a/app/src/main/java/foundation/e/drive/periodicScan/contentScanner/LocalFileLister.java b/app/src/main/java/foundation/e/drive/periodicScan/contentScanner/LocalFileLister.java index 11d2c58d..e95354c0 100644 --- a/app/src/main/java/foundation/e/drive/periodicScan/contentScanner/LocalFileLister.java +++ b/app/src/main/java/foundation/e/drive/periodicScan/contentScanner/LocalFileLister.java @@ -105,7 +105,7 @@ public class LocalFileLister extends AbstractFileLister { folder = new FolderWrapper(dir); final String category = syncedFolder.isMediaType() ? "media" : syncedFolder.getLibelle(); - final FileFilter filter = FileFilterFactory.getFileFilter(category); + final FileFilter filter = FileFilterFactory.buildFileFilter(category); final File[] files = dir.listFiles(filter); if (files != null) { folder.addContent(Arrays.asList(files)); -- GitLab From f422030db74d9c3a4824f38b0f41c529bba36de7 Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Mon, 8 Jan 2024 19:52:29 +0600 Subject: [PATCH 3/4] implement multiple partFile check utils methods. --- .../foundation/e/drive/fileObservers/FileEventHandler.kt | 2 +- app/src/main/java/foundation/e/drive/utils/FileUtils.kt | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/fileObservers/FileEventHandler.kt b/app/src/main/java/foundation/e/drive/fileObservers/FileEventHandler.kt index 144f05ac..480fc48b 100644 --- a/app/src/main/java/foundation/e/drive/fileObservers/FileEventHandler.kt +++ b/app/src/main/java/foundation/e/drive/fileObservers/FileEventHandler.kt @@ -33,7 +33,7 @@ import java.io.File class FileEventHandler(private val context: Context) { fun onEvent(event: Int, file: File) { - if (!FileUtils.isNotPartFile(file)) { + if (FileUtils.isPartFile(file)) { return } diff --git a/app/src/main/java/foundation/e/drive/utils/FileUtils.kt b/app/src/main/java/foundation/e/drive/utils/FileUtils.kt index 774df298..2a7c87ee 100644 --- a/app/src/main/java/foundation/e/drive/utils/FileUtils.kt +++ b/app/src/main/java/foundation/e/drive/utils/FileUtils.kt @@ -68,5 +68,8 @@ object FileUtils { } @JvmStatic - fun isNotPartFile(file: File) = !file.name.endsWith(".part") + fun isPartFile(file: File) = file.name.endsWith(".part") + + @JvmStatic + fun isNotPartFile(file: File) = !isPartFile(file) } \ No newline at end of file -- GitLab From 882cc34e95e8049bfcd929173b908abbeba965da Mon Sep 17 00:00:00 2001 From: Fahim Salam Chowdhury Date: Mon, 8 Jan 2024 19:55:21 +0600 Subject: [PATCH 4/4] fix build issue --- .../java/foundation/e/drive/fileFilters/FileFilterFactory.kt | 2 +- .../e/drive/periodicScan/contentScanner/LocalFileLister.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/foundation/e/drive/fileFilters/FileFilterFactory.kt b/app/src/main/java/foundation/e/drive/fileFilters/FileFilterFactory.kt index 0118c8c2..cf7fd21e 100644 --- a/app/src/main/java/foundation/e/drive/fileFilters/FileFilterFactory.kt +++ b/app/src/main/java/foundation/e/drive/fileFilters/FileFilterFactory.kt @@ -27,7 +27,7 @@ import java.io.FileFilter */ object FileFilterFactory { - fun buildFileFilter(category: String): FileFilter { + fun buildFileFilter(category: String?): FileFilter { return when (category) { "Rom settings" -> buildSettingsFilter() "Applications" -> buildAppSettingsFilter() diff --git a/app/src/main/java/foundation/e/drive/periodicScan/contentScanner/LocalFileLister.java b/app/src/main/java/foundation/e/drive/periodicScan/contentScanner/LocalFileLister.java index e95354c0..43bc0662 100644 --- a/app/src/main/java/foundation/e/drive/periodicScan/contentScanner/LocalFileLister.java +++ b/app/src/main/java/foundation/e/drive/periodicScan/contentScanner/LocalFileLister.java @@ -105,7 +105,7 @@ public class LocalFileLister extends AbstractFileLister { folder = new FolderWrapper(dir); final String category = syncedFolder.isMediaType() ? "media" : syncedFolder.getLibelle(); - final FileFilter filter = FileFilterFactory.buildFileFilter(category); + final FileFilter filter = FileFilterFactory.INSTANCE.buildFileFilter(category); final File[] files = dir.listFiles(filter); if (files != null) { folder.addContent(Arrays.asList(files)); -- GitLab