Browse Source

NPE on download

Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
tobiasKaminsky 4 years ago
parent
commit
06ad76979a

+ 5 - 4
src/main/java/com/owncloud/android/files/services/FileDownloader.java

@@ -455,10 +455,7 @@ public class FileDownloader extends Service
 
                     // always get client from client manager, to get fresh credentials in case
                     // of update
-                    OwnCloudAccount ocAccount = new OwnCloudAccount(
-                            mCurrentAccount,
-                            this
-                    );
+                    OwnCloudAccount ocAccount = new OwnCloudAccount(mCurrentAccount, this);
                     mDownloadClient = OwnCloudClientManagerFactory.getDefaultSingleton().
                             getClientFor(ocAccount, this);
 
@@ -477,6 +474,10 @@ public class FileDownloader extends Service
                     Pair<DownloadFileOperation, String> removeResult = mPendingDownloads.removePayload(
                         mCurrentAccount.name, mCurrentDownload.getRemotePath());
 
+                    if (downloadResult == null) {
+                        downloadResult = new RemoteOperationResult(new RuntimeException("Error downloading…"));
+                    }
+
                     /// notify result
                     notifyDownloadResult(mCurrentDownload, downloadResult);