File tree Expand file tree Collapse file tree 1 file changed +22
-8
lines changed
app/src/main/java/com/raival/compose/file/explorer/screen/main/tab/files/task Expand file tree Collapse file tree 1 file changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import net.lingala.zip4j.ZipFile
1515import net.lingala.zip4j.model.ZipParameters
1616import java.io.ByteArrayInputStream
1717import java.io.File
18+ import java.nio.file.AtomicMoveNotSupportedException
1819import java.nio.file.Files
1920import java.nio.file.StandardCopyOption
2021
@@ -372,14 +373,27 @@ class CopyTask(
372373 if (source.isFile) {
373374 destination.parentFile?.mkdirs()
374375 if (deleteSourceFiles) {
375- Files .move(
376- source.toPath(),
377- destination.toPath(),
378- * buildList {
379- add(StandardCopyOption .ATOMIC_MOVE )
380- if (overwrite) add(StandardCopyOption .REPLACE_EXISTING )
381- }.toTypedArray()
382- )
376+ try {
377+ // Try atomic move first (faster when supported)
378+ Files .move(
379+ source.toPath(),
380+ destination.toPath(),
381+ * buildList {
382+ add(StandardCopyOption .ATOMIC_MOVE )
383+ if (overwrite) add(StandardCopyOption .REPLACE_EXISTING )
384+ }.toTypedArray()
385+ )
386+ } catch (_: AtomicMoveNotSupportedException ) {
387+ // Fallback to copy only - deletion will be handled by performSourceDeletion()
388+ Files .copy(
389+ source.toPath(),
390+ destination.toPath(),
391+ * buildList {
392+ add(StandardCopyOption .COPY_ATTRIBUTES )
393+ if (overwrite) add(StandardCopyOption .REPLACE_EXISTING )
394+ }.toTypedArray()
395+ )
396+ }
383397 } else {
384398 source.copyTo(destination, overwrite)
385399 }
You can’t perform that action at this time.
0 commit comments