fix: simplifications
- Change all `CloudNode` to `PCloudNode` - Check `replace` before `exists()` - Move definition of relocationEntry below exception - Change `CloudFile` to `PCloudFile`
This commit is contained in:
parent
b6cebf16fb
commit
90c7c14471
@ -96,7 +96,7 @@ class PCloudCloudContentRepository extends InterceptingCloudContentRepository<PC
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<CloudNode> list(PCloudFolder folder) throws BackendException {
|
public List<PCloudNode> list(PCloudFolder folder) throws BackendException {
|
||||||
try {
|
try {
|
||||||
return cloud.list(folder);
|
return cloud.list(folder);
|
||||||
} catch (ApiError | IOException e) {
|
} catch (ApiError | IOException e) {
|
||||||
|
@ -165,8 +165,8 @@ class PCloudImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<CloudNode> list(PCloudFolder folder) throws ApiError, IOException {
|
public List<PCloudNode> list(PCloudFolder folder) throws ApiError, IOException {
|
||||||
List<CloudNode> result = new ArrayList<>();
|
List<PCloudNode> result = new ArrayList<>();
|
||||||
|
|
||||||
Long folderId = folder.getId();
|
Long folderId = folder.getId();
|
||||||
RemoteFolder listFolderResult;
|
RemoteFolder listFolderResult;
|
||||||
@ -201,12 +201,13 @@ class PCloudImpl {
|
|||||||
PCloudCloudNodeFactory.folder(folder.getParent(), createdFolder));
|
PCloudCloudNodeFactory.folder(folder.getParent(), createdFolder));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CloudNode move(PCloudNode source, PCloudNode target) throws ApiError, BackendException, IOException {
|
public PCloudNode move(PCloudNode source, PCloudNode target) throws ApiError, BackendException, IOException {
|
||||||
RemoteEntry relocationResult;
|
|
||||||
if (exists(target)) {
|
if (exists(target)) {
|
||||||
throw new CloudNodeAlreadyExistsException(target.getName());
|
throw new CloudNodeAlreadyExistsException(target.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemoteEntry relocationResult;
|
||||||
|
|
||||||
if (source instanceof PCloudFolder) {
|
if (source instanceof PCloudFolder) {
|
||||||
relocationResult = client().moveFolder(source.getId(), target.getParent().getId()).execute();
|
relocationResult = client().moveFolder(source.getId(), target.getParent().getId()).execute();
|
||||||
if (!relocationResult.name().equals(target.getName())) {
|
if (!relocationResult.name().equals(target.getName())) {
|
||||||
@ -225,7 +226,7 @@ class PCloudImpl {
|
|||||||
|
|
||||||
public PCloudFile write(PCloudFile file, DataSource data, final ProgressAware<UploadState> progressAware, boolean replace, long size)
|
public PCloudFile write(PCloudFile file, DataSource data, final ProgressAware<UploadState> progressAware, boolean replace, long size)
|
||||||
throws ApiError, BackendException, IOException {
|
throws ApiError, BackendException, IOException {
|
||||||
if (exists(file) && !replace) {
|
if (!replace && exists(file)) {
|
||||||
throw new CloudNodeAlreadyExistsException("CloudNode already exists and replace is false");
|
throw new CloudNodeAlreadyExistsException("CloudNode already exists and replace is false");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,10 +279,10 @@ class PCloudImpl {
|
|||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void read(CloudFile file, OutputStream data, final ProgressAware<DownloadState> progressAware) throws ApiError, IOException {
|
public void read(PCloudFile file, OutputStream data, final ProgressAware<DownloadState> progressAware) throws ApiError, IOException {
|
||||||
progressAware.onProgress(Progress.started(DownloadState.download(file)));
|
progressAware.onProgress(Progress.started(DownloadState.download(file)));
|
||||||
|
|
||||||
Long fileId = ((PCloudFile)file).getId();
|
Long fileId = file.getId();
|
||||||
if (fileId == null) {
|
if (fileId == null) {
|
||||||
fileId = idCache.get(file.getPath()).getId();
|
fileId = idCache.get(file.getPath()).getId();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user