Fix null pointer after uploading backup file

pull/1143/head
Alex Baker 5 years ago
parent 7f79510c6d
commit 76144ba7d2

@ -49,8 +49,8 @@ object BackupConstants {
return getTimestampFromFilename(file.name) ?: file.lastModified()
}
fun getTimestamp(file: File): Long {
return getTimestampFromFilename(file.name) ?: file.modifiedTime.value
fun getTimestamp(file: File): Long? {
return getTimestampFromFilename(file.name) ?: file.modifiedTime?.value
}
fun getTimestamp(file: DocumentFile): Long {

@ -144,7 +144,7 @@ class DriveInvoker @Inject constructor(
companion object {
private const val MIME_FOLDER = "application/vnd.google-apps.folder"
private val DRIVE_FILE_COMPARATOR = Comparator<File> { f1, f2 ->
BackupConstants.getTimestamp(f2).compareTo(BackupConstants.getTimestamp(f1))
BackupConstants.getTimestamp(f2)!!.compareTo(BackupConstants.getTimestamp(f1)!!)
}
}
}

@ -40,12 +40,8 @@ class DriveUploader @WorkerInject constructor(
val folder = getFolder() ?: return Result.failure()
preferences.setString(R.string.p_google_drive_backup_folder, folder.id)
drive.createFile(folder.id, uri)
?.let {
preferences.setLong(
R.string.p_backups_drive_last,
BackupConstants.getTimestamp(it)
)
}
?.let(BackupConstants::getTimestamp)
?.let { preferences.setLong(R.string.p_backups_drive_last, it) }
localBroadcastManager.broadcastPreferenceRefresh()
if (inputData.getBoolean(EXTRA_PURGE, false)) {
drive

Loading…
Cancel
Save