2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-31 14:15:14 +00:00

Share plugin: Honor received last modified metadata

This commit is contained in:
Albert Vaca Cintora
2022-03-06 12:49:08 +01:00
parent 4fa634afa4
commit f628bbdabc

View File

@@ -32,6 +32,9 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.attribute.FileTime;
import java.util.ArrayList;
import java.util.List;
@@ -162,6 +165,18 @@ public class CompositeReceiveFileJob extends BackgroundJob<Device, Void> {
publishFile(fileDocument, 0);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (currentNetworkPacket.has("lastModified")) {
try {
long lastModified = currentNetworkPacket.getLong("lastModified");
Files.setLastModifiedTime(Paths.get(fileDocument.getUri().getPath()), FileTime.fromMillis(lastModified));
} catch (Exception e) {
Log.e("SharePlugin", "Can't set date on file");
e.printStackTrace();
}
}
}
boolean listIsEmpty;
synchronized (lock) {