keep last modified field at recycle bin operations, when expected

This commit is contained in:
tibbi 2019-05-26 10:38:23 +02:00
parent f20ef872ca
commit bd36ce4ce9

View file

@ -231,10 +231,15 @@ fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList<String>, mediumDao
paths.forEach {
val file = File(it)
val internalFile = File(recycleBinPath, it)
val lastModified = file.lastModified()
try {
if (file.copyRecursively(internalFile, true)) {
mediumDao.updateDeleted("$RECYCLE_BIN$it", System.currentTimeMillis(), it)
pathsCnt--
if (config.keepLastModified) {
internalFile.setLastModified(lastModified)
}
}
} catch (e: Exception) {
showErrorToast(e)
@ -255,6 +260,7 @@ fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList<String>, mediumDa
paths.forEach {
val source = it
val destination = it.removePrefix(recycleBinPath)
val lastModified = File(source).lastModified()
var inputStream: InputStream? = null
var out: OutputStream? = null
@ -266,6 +272,10 @@ fun BaseSimpleActivity.restoreRecycleBinPaths(paths: ArrayList<String>, mediumDa
mediumDao.updateDeleted(destination.removePrefix(recycleBinPath), 0, "$RECYCLE_BIN$destination")
}
newPaths.add(destination)
if (config.keepLastModified) {
File(destination).setLastModified(lastModified)
}
} catch (e: Exception) {
showErrorToast(e)
} finally {