From aec189aab33585c439008cfb673ab723723c7387 Mon Sep 17 00:00:00 2001 From: Benjamin Gonzalez Date: Wed, 13 Mar 2024 20:27:39 -0500 Subject: [PATCH] Allow cross-drive moving --- lib/moving.dart | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/moving.dart b/lib/moving.dart index e995a0e8..a94416dc 100644 --- a/lib/moving.dart +++ b/lib/moving.dart @@ -131,18 +131,16 @@ Stream moveFiles( moveFile() async { final freeFile = findNotExistingName( File(p.join(folder.path, p.basename(file.value.path)))); - try { - return copy - ? await file.value.copy(freeFile.path) - : await file.value.rename(freeFile.path); - } on FileSystemException { - print( - "Uh-uh, it looks like you selected other output drive than\n" - "input one - gpth can't move files between them. But, you don't have\n" - "to do this! Gpth *moves* files, so this doesn't take any extra space!\n" - "Please run again and select different output location <3", - ); - quit(1); + if (copy) { + return await file.value.copy(freeFile.path); + } else { + try { + return await file.value.rename(freeFile.path); + } on FileSystemException { + var temp = await file.value.copy(freeFile.path); + await file.value.delete(); + return temp; + } } }