Truncate files after possible overwrite

This commit is contained in:
Matéo Duparc 2022-09-13 10:33:14 +02:00
parent e2539a53b9
commit 2d19895e6d
Signed by: hardcoresushi
GPG Key ID: AFE384344A45E13A
2 changed files with 3 additions and 0 deletions

View File

@ -141,6 +141,7 @@ class FileOperationService : Service() {
break
}
}
encryptedVolume.truncate(dstPath, offset)
encryptedVolume.closeFile(dstFileHandle)
} else {
success = false

View File

@ -77,6 +77,7 @@ abstract class EncryptedVolume: Parcelable {
abstract fun read(fileHandle: Long, buffer: ByteArray, offset: Long): Int
abstract fun write(fileHandle: Long, offset: Long, buffer: ByteArray, size: Int): Int
abstract fun closeFile(fileHandle: Long): Boolean
// Due to gocryptfs internals, truncate requires the file to be open before it is called
abstract fun truncate(path: String, size: Long): Boolean
abstract fun deleteFile(path: String): Boolean
abstract fun readDir(path: String): MutableList<ExplorerElement>?
@ -142,6 +143,7 @@ abstract class EncryptedVolume: Parcelable {
break
}
}
truncate(dst_path, offset)
closeFile(dstfileHandle)
inputStream.close()
return success