Browse Source

Merge pull request #9350 from nextcloud/fix-npe-regression-in-file-downloader

Fix NPE regression in FileDownloader
Álvaro Brey 3 years ago
parent
commit
85fd9d4f8d

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

@@ -105,7 +105,7 @@ public class FileDownloader extends Service
     private ServiceHandler mServiceHandler;
     private IBinder mBinder;
     private OwnCloudClient mDownloadClient;
-    private Optional<User> currentUser;
+    private Optional<User> currentUser = Optional.empty();
     private FileDataStorageManager mStorageManager;
 
     private IndexedForest<DownloadFileOperation> mPendingDownloads = new IndexedForest<>();
@@ -483,7 +483,7 @@ public class FileDownloader extends Service
 
                 } finally {
                     Pair<DownloadFileOperation, String> removeResult = mPendingDownloads.removePayload(
-                        currentUser.get().getAccountName(), mCurrentDownload.getRemotePath());
+                        mCurrentDownload.getUser().getAccountName(), mCurrentDownload.getRemotePath());
 
                     if (downloadResult == null) {
                         downloadResult = new RemoteOperationResult(new RuntimeException("Error downloading…"));