Fix Dropbox vault unlock in vault version 7 and caching enabled

This commit is contained in:
Julian Raufelder 2021-07-07 16:58:43 +02:00
parent 543a03212f
commit 3ae90ab521
No known key found for this signature in database
GPG Key ID: 17EE71F6634E381D

View File

@ -7,6 +7,7 @@ import com.dropbox.core.NetworkIOException
import com.dropbox.core.v2.files.CreateFolderErrorException
import com.dropbox.core.v2.files.DeleteErrorException
import com.dropbox.core.v2.files.DownloadErrorException
import com.dropbox.core.v2.files.GetMetadataErrorException
import com.dropbox.core.v2.files.ListFolderErrorException
import com.dropbox.core.v2.files.RelocationErrorException
import org.cryptomator.data.cloud.InterceptingCloudContentRepository
@ -157,22 +158,26 @@ internal class DropboxCloudContentRepository(private val cloud: DropboxCloud, co
try {
cloud.read(file, encryptedTmpFile, data, progressAware)
} catch (e: IOException) {
if (ExceptionUtil.contains(e, DownloadErrorException::class.java)) {
if (ExceptionUtil.extract(e, DownloadErrorException::class.java).get().errorValue.pathValue.isNotFound) {
throw NoSuchCloudFileException(file.name)
}
}
throw FatalBackendException(e)
mapToNoSuchCloudFileExceptionIfMatches(e, file)?.let { throw it } ?: throw FatalBackendException(e)
} catch (e: DbxException) {
if (ExceptionUtil.contains(e, DownloadErrorException::class.java)) {
if (ExceptionUtil.extract(e, DownloadErrorException::class.java).get().errorValue.pathValue.isNotFound) {
throw NoSuchCloudFileException(file.name)
}
}
throw FatalBackendException(e)
mapToNoSuchCloudFileExceptionIfMatches(e, file)?.let { throw it } ?: throw FatalBackendException(e)
}
}
private fun mapToNoSuchCloudFileExceptionIfMatches(e: Exception, file: DropboxFile) : NoSuchCloudFileException? {
if (ExceptionUtil.contains(e, GetMetadataErrorException::class.java)) {
if (ExceptionUtil.extract(e, GetMetadataErrorException::class.java).get().errorValue.pathValue.isNotFound) {
return NoSuchCloudFileException(file.name)
}
}
else if (ExceptionUtil.contains(e, DownloadErrorException::class.java)) {
if (ExceptionUtil.extract(e, DownloadErrorException::class.java).get().errorValue.pathValue.isNotFound) {
return NoSuchCloudFileException(file.name)
}
}
return null
}
@Throws(BackendException::class)
override fun delete(node: DropboxNode) {
try {