From 0e5062a599c569767acb0f86b17c891cb3fda21c Mon Sep 17 00:00:00 2001 From: VishnuSanal Date: Tue, 7 May 2024 21:30:35 +0530 Subject: [PATCH 1/2] fixes #892 --- .../asynchronous/services/CopyService.java | 2 ++ .../amaze/filemanager/filesystem/HybridFile.java | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/asynchronous/services/CopyService.java b/app/src/main/java/com/amaze/filemanager/asynchronous/services/CopyService.java index 58ae8a0448..0e03e0dfb2 100644 --- a/app/src/main/java/com/amaze/filemanager/asynchronous/services/CopyService.java +++ b/app/src/main/java/com/amaze/filemanager/asynchronous/services/CopyService.java @@ -501,6 +501,7 @@ private void copyFiles( file.isDirectory()); try { copyFiles(file, destFile, progressHandler); + destFile.setLastModified(file.lastModified()); } catch (IOException e) { throw new IllegalStateException(e); // throw unchecked exception, no throws needed } @@ -522,6 +523,7 @@ private void copyFiles( AppConfig.toast(c, c.getString(R.string.copy_low_memory)); }, ServiceWatcherUtil.UPDATE_POSITION); + targetFile.setLastModified(sourceFile.lastModified()); } } } diff --git a/app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java b/app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java index ac9dc8b25d..af0b9902ab 100644 --- a/app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java +++ b/app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java @@ -39,6 +39,8 @@ import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URLDecoder; +import java.nio.file.Files; +import java.nio.file.attribute.FileTime; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; @@ -1440,8 +1442,15 @@ public Boolean execute(@NonNull Session session) throws IOException { // do nothing return true; } else { - File f = getFile(); - return f.setLastModified(date); + if (getFile().setLastModified(date)) return true; + + try { + Files.setLastModifiedTime(getFile().toPath(), FileTime.fromMillis(date)); + return true; + } catch (IOException e) { + LOG.error("Files#setLastModifiedTime", e); + return false; + } } } From eef506c94d28666e2e1c04deb1055623e7c3ab01 Mon Sep 17 00:00:00 2001 From: VishnuSanal Date: Tue, 4 Jun 2024 08:37:05 +0530 Subject: [PATCH 2/2] fixes #892 --- .../amaze/filemanager/filesystem/HybridFile.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java b/app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java index af0b9902ab..7a900475c4 100644 --- a/app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java +++ b/app/src/main/java/com/amaze/filemanager/filesystem/HybridFile.java @@ -1444,13 +1444,16 @@ public Boolean execute(@NonNull Session session) throws IOException { } else { if (getFile().setLastModified(date)) return true; - try { - Files.setLastModifiedTime(getFile().toPath(), FileTime.fromMillis(date)); - return true; - } catch (IOException e) { - LOG.error("Files#setLastModifiedTime", e); - return false; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + try { + Files.setLastModifiedTime(getFile().toPath(), FileTime.fromMillis(date)); + return true; + } catch (IOException e) { + LOG.error("Files#setLastModifiedTime", e); + return false; + } } + return false; } }