fix: make fileid null safe

This commit is contained in:
Manuel Jenny 2021-03-16 15:54:01 +01:00
parent c29801f132
commit ceb2de61d4
No known key found for this signature in database
GPG Key ID: 1C80FE62B2BEAA18

View File

@ -205,7 +205,12 @@ class PCloudImpl {
public void read(CloudFile file, OutputStream data, final ProgressAware<DownloadState> progressAware) throws ApiError, IOException {
progressAware.onProgress(Progress.started(DownloadState.download(file)));
FileLink fileLink = client().createFileLink(((PCloudFile) file).getId(), DownloadOptions.DEFAULT).execute();
Long fileId = ((PCloudFile)file).getId();
if (fileId == null) {
fileId = client().stat(file.getPath()).execute().fileId();
}
FileLink fileLink = client().createFileLink(fileId, DownloadOptions.DEFAULT).execute();
ProgressListener listener = (done, total) -> progressAware.onProgress( //
progress(DownloadState.download(file)) //