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