Skip to content

Commit

Permalink
Merge branch 'develop' into feature/dao-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
JaniruTEC committed Oct 27, 2023
2 parents 4809e4a + accc172 commit 4cce1eb
Show file tree
Hide file tree
Showing 104 changed files with 458 additions and 420 deletions.
38 changes: 36 additions & 2 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def liteFlavor() {
}

def getApiKeyLocal(key) {
if(!rootProject.file("local.properties").exists()) {
if (!rootProject.file("local.properties").exists()) {
return ""
}
def localPropertyList = new Properties()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import java.io.File
import java.io.IOException
import java.io.OutputStream

internal class DropboxCloudContentRepository(private val cloud: DropboxCloud, context: Context) : InterceptingCloudContentRepository<DropboxCloud, DropboxNode, DropboxFolder, DropboxFile>(Intercepted(cloud, context)){
internal class DropboxCloudContentRepository(private val cloud: DropboxCloud, context: Context) : InterceptingCloudContentRepository<DropboxCloud, DropboxNode, DropboxFolder, DropboxFile>(Intercepted(cloud, context)) {

@Throws(BackendException::class)
override fun throwWrappedIfRequired(e: Exception) {
Expand Down Expand Up @@ -164,13 +164,12 @@ internal class DropboxCloudContentRepository(private val cloud: DropboxCloud, co
}
}

private fun mapToNoSuchCloudFileExceptionIfMatches(e: Exception, file: DropboxFile) : NoSuchCloudFileException? {
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)) {
} else if (ExceptionUtil.contains(e, DownloadErrorException::class.java)) {
if (ExceptionUtil.extract(e, DownloadErrorException::class.java).get().errorValue.pathValue.isNotFound) {
return NoSuchCloudFileException(file.name)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.cryptomator.data.cloud.dropbox;

import static org.cryptomator.domain.CloudType.DROPBOX;

import android.content.Context;

import org.cryptomator.data.repository.CloudContentRepositoryFactory;
Expand All @@ -12,6 +10,8 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import static org.cryptomator.domain.CloudType.DROPBOX;

@Singleton
public class DropboxCloudContentRepositoryFactory implements CloudContentRepositoryFactory {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import java.io.OutputStream
import java.net.SocketTimeoutException
import okhttp3.Request

internal class OnedriveCloudContentRepository(private val cloud: OnedriveCloud, graphServiceClient: GraphServiceClient<Request>, context: Context)
: InterceptingCloudContentRepository<OnedriveCloud, OnedriveNode, OnedriveFolder, OnedriveFile>(Intercepted(cloud, graphServiceClient, context)) {
internal class OnedriveCloudContentRepository(private val cloud: OnedriveCloud, graphServiceClient: GraphServiceClient<Request>, context: Context) :
InterceptingCloudContentRepository<OnedriveCloud, OnedriveNode, OnedriveFolder, OnedriveFile>(Intercepted(cloud, graphServiceClient, context)) {

@Throws(BackendException::class)
override fun throwWrappedIfRequired(e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.cryptomator.data.cloud.onedrive;

import static org.cryptomator.domain.CloudType.ONEDRIVE;

import android.content.Context;

import org.cryptomator.data.repository.CloudContentRepositoryFactory;
Expand All @@ -12,6 +10,8 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import static org.cryptomator.domain.CloudType.ONEDRIVE;

@Singleton
public class OnedriveCloudContentRepositoryFactory implements CloudContentRepositoryFactory {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ interface OnedriveNode : CloudNode {
override val name: String
override val path: String
override val parent: OnedriveFolder?

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.cryptomator.data.cloud.pcloud

import java.util.HashSet

object PCloudApiError {

@JvmField
Expand All @@ -14,6 +12,7 @@ object PCloudApiError {
PCloudApiErrorCodes.INVALID_FILE_OR_FOLDER_NAME.value //
)
)

@JvmField
val ignoreMoveSet = HashSet( //
listOf( //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import java.io.File
import java.io.IOException
import java.io.OutputStream

internal class PCloudContentRepository(private val cloud: PCloud, client: ApiClient, context: Context) : InterceptingCloudContentRepository<PCloud, PCloudNode, PCloudFolder, PCloudFile>(Intercepted(cloud, client, context)) {
internal class PCloudContentRepository(private val cloud: PCloud, client: ApiClient, context: Context) :
InterceptingCloudContentRepository<PCloud, PCloudNode, PCloudFolder, PCloudFile>(Intercepted(cloud, client, context)) {

@Throws(BackendException::class)
override fun throwWrappedIfRequired(e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.cryptomator.data.cloud.pcloud;

import static org.cryptomator.domain.CloudType.PCLOUD;

import android.content.Context;

import org.cryptomator.data.repository.CloudContentRepositoryFactory;
Expand All @@ -12,6 +10,8 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import static org.cryptomator.domain.CloudType.PCLOUD;

@Singleton
public class PCloudContentRepositoryFactory implements CloudContentRepositoryFactory {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.cryptomator.data.cloud;

import static java.util.Arrays.asList;

import org.cryptomator.data.cloud.crypto.CryptoCloudContentRepositoryFactory;
import org.cryptomator.data.cloud.dropbox.DropboxCloudContentRepositoryFactory;
import org.cryptomator.data.cloud.googledrive.GoogleDriveCloudContentRepositoryFactory;
Expand All @@ -18,6 +16,8 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import static java.util.Arrays.asList;

@Singleton
public class CloudContentRepositoryFactories implements Iterable<CloudContentRepositoryFactory> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ internal class GoogleDriveImpl(context: Context, googleDriveCloud: GoogleDriveCl
folder?.let {
if (GoogleDriveCloudNodeFactory.isFolder(it)) {
return idCache.cache(GoogleDriveCloudNodeFactory.folder(parent, it))
} else if(GoogleDriveCloudNodeFactory.isShortcutFolder(it)) {
} else if (GoogleDriveCloudNodeFactory.isShortcutFolder(it)) {
return idCache.cache(GoogleDriveCloudNodeFactory.folder(parent, name, path, it.shortcutDetails.targetId))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ public class CloudContentRepositoryFactories implements Iterable<CloudContentRep
private final Iterable<CloudContentRepositoryFactory> factories;

@Inject
public CloudContentRepositoryFactories(
S3CloudContentRepositoryFactory s3Factory, //
public CloudContentRepositoryFactories(S3CloudContentRepositoryFactory s3Factory, //
CryptoCloudContentRepositoryFactory cryptoFactory, //
LocalStorageContentRepositoryFactory localStorageFactory, //
WebDavCloudContentRepositoryFactory webDavFactory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import dagger.Lazy;

import static java.lang.String.format;
import static org.cryptomator.domain.CloudType.CRYPTO;
import static java.lang.String.format;

@Singleton
public class CryptoCloudContentRepositoryFactory implements CloudContentRepositoryFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal class LocalStorageAccessFrameworkImpl(private val context: Context, pri
return file(parent, name, path, size, nodeInfo.id)
}
listFilesWithNameFilter(parent, name).getOrNull(0)?.let {
if(it is LocalStorageAccessFile) {
if (it is LocalStorageAccessFile) {
return idCache.cache(it)
}
}
Expand All @@ -94,7 +94,7 @@ internal class LocalStorageAccessFrameworkImpl(private val context: Context, pri
return folder(parent, name, nodeInfo.id)
}
listFilesWithNameFilter(parent, name).getOrNull(0)?.let {
if(it is LocalStorageAccessFolder) {
if (it is LocalStorageAccessFolder) {
return idCache.cache(it)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.cryptomator.data.cloud.local;

import static org.cryptomator.domain.CloudType.LOCAL;

import android.content.Context;
import android.content.UriPermission;

Expand All @@ -17,6 +15,8 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import static org.cryptomator.domain.CloudType.LOCAL;

@Singleton
public class LocalStorageContentRepositoryFactory implements CloudContentRepositoryFactory {

Expand All @@ -38,7 +38,7 @@ public boolean supports(Cloud cloud) {
public CloudContentRepository cloudContentRepositoryFor(Cloud cloud) {
List<UriPermission> permissions = context.getContentResolver().getPersistedUriPermissions();
for (UriPermission permission : permissions) {
if(permission.getUri().toString().equals(((LocalStorageCloud) cloud).rootUri())) {
if (permission.getUri().toString().equals(((LocalStorageCloud) cloud).rootUri())) {
return new LocalStorageAccessFrameworkContentRepository(context, mimeTypes, (LocalStorageCloud) cloud);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.cryptomator.data.cloud.okhttplogging

import java.util.HashSet

internal class HeaderNames(vararg headerNames: String) {

private val lowercaseNames: MutableSet<String> = HashSet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class HttpLoggingInterceptor(private val logger: Logger, private val context: Co
}

interface Logger {

fun log(message: String)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.cryptomator.data.cloud.s3;

import static org.cryptomator.domain.CloudType.S3;

import android.content.Context;

import org.cryptomator.data.repository.CloudContentRepositoryFactory;
Expand All @@ -13,6 +11,8 @@
import javax.inject.Inject;
import javax.inject.Singleton;

import static org.cryptomator.domain.CloudType.S3;

@Singleton
public class S3CloudContentRepositoryFactory implements CloudContentRepositoryFactory {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal object S3CloudNodeFactory {
private const val DELIMITER = "/"

fun file(parent: S3Folder, name: String): S3File {
return S3File(parent, name, getNodePath(parent, name), null, null)
return S3File(parent, name, getNodePath(parent, name), null, null)
}

fun file(parent: S3Folder, name: String, size: Long?): S3File {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal open class S3Folder(override val parent: S3Folder?, override val name:
}

companion object {

private const val DELIMITER = "/"
}
}
28 changes: 14 additions & 14 deletions data/src/main/java/org/cryptomator/data/cloud/s3/S3Impl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -342,21 +342,21 @@ internal class S3Impl(private val cloud: S3Cloud, private val client: MinioClien
}

private fun handleApiError(e: ErrorResponseException, name: String): Exception {
val errorCode = e.errorResponse().code()
return when {
isAccessProblem(errorCode) -> {
ForbiddenException()
}
S3CloudApiErrorCodes.NO_SUCH_BUCKET.value == errorCode -> {
NoSuchBucketException(name)
}
S3CloudApiErrorCodes.NO_SUCH_KEY.value == errorCode -> {
NoSuchCloudFileException(name)
}
else -> {
FatalBackendException(e)
}
val errorCode = e.errorResponse().code()
return when {
isAccessProblem(errorCode) -> {
ForbiddenException()
}
S3CloudApiErrorCodes.NO_SUCH_BUCKET.value == errorCode -> {
NoSuchBucketException(name)
}
S3CloudApiErrorCodes.NO_SUCH_KEY.value == errorCode -> {
NoSuchCloudFileException(name)
}
else -> {
FatalBackendException(e)
}
}
}

fun logout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal class PropfindEntryData {
fun setPath(pathOrUri: String) {
path = extractPath(pathOrUri).also {
var pathSegs = it.split("/")
if(pathSegs.last() == "") {
if (pathSegs.last() == "") {
pathSegs = pathSegs.subList(0, pathSegs.size - 1)
}
pathSegments = pathSegs.toTypedArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import org.xmlpull.v1.XmlPullParserException
import org.xmlpull.v1.XmlPullParserFactory
import java.io.IOException
import java.io.InputStream
import java.util.ArrayList
import java.util.Date
import timber.log.Timber

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class NetworkConnectionCheck @Inject internal constructor(private val context: C

fun checkWifiOnAndConnected(): Boolean {
val connectivityManager = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val activeNetwork = connectivityManager.activeNetwork
return connectivityManager.getNetworkCapabilities(activeNetwork)?.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) == true
val activeNetwork = connectivityManager.activeNetwork
return connectivityManager.getNetworkCapabilities(activeNetwork)?.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) == true
}
}
Loading

0 comments on commit 4cce1eb

Please sign in to comment.