mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-29 01:48:53 +03:00
check if location of cached file makes sense
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
d49441e036
commit
bd23edc9a5
2 changed files with 10 additions and 2 deletions
|
@ -126,7 +126,9 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa
|
||||||
|
|
||||||
initNotificationSetup()
|
initNotificationSetup()
|
||||||
|
|
||||||
if (file != null && file.length() > CHUNK_UPLOAD_THRESHOLD_SIZE) {
|
if (file == null) {
|
||||||
|
uploadSuccess = false
|
||||||
|
} else if (file.length() > CHUNK_UPLOAD_THRESHOLD_SIZE) {
|
||||||
Log.d(TAG, "starting chunked upload because size is " + file.length())
|
Log.d(TAG, "starting chunked upload because size is " + file.length())
|
||||||
|
|
||||||
initNotificationWithPercentage()
|
initNotificationWithPercentage()
|
||||||
|
|
|
@ -112,9 +112,15 @@ object FileUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("NestedBlockDepth")
|
@Suppress("NestedBlockDepth")
|
||||||
fun copyFileToCache(context: Context, sourceFileUri: Uri, filename: String): File {
|
fun copyFileToCache(context: Context, sourceFileUri: Uri, filename: String): File? {
|
||||||
val cachedFile = File(context.cacheDir, filename)
|
val cachedFile = File(context.cacheDir, filename)
|
||||||
|
|
||||||
|
if (!cachedFile.canonicalPath.startsWith(context.cacheDir.canonicalPath, true)) {
|
||||||
|
Log.w(TAG, "cachedFile was not created in cacheDir. Aborting for security reasons.")
|
||||||
|
cachedFile.delete()
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
if (cachedFile.exists()) {
|
if (cachedFile.exists()) {
|
||||||
Log.d(TAG, "file is already in cache")
|
Log.d(TAG, "file is already in cache")
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue