mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 08:30:44 +00:00
Merge pull request #6778 from Stypox/invalid-storage-npe
Fix NullPointerException when checking if storage exists
This commit is contained in:
commit
cd713db029
@ -8,6 +8,7 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Environment;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -15,6 +16,7 @@ import androidx.documentfile.provider.DocumentFile;
|
||||
|
||||
import com.nononsenseapps.filepicker.Utils;
|
||||
|
||||
import org.schabi.newpipe.MainActivity;
|
||||
import org.schabi.newpipe.settings.NewPipeSettings;
|
||||
import org.schabi.newpipe.util.FilePickerActivityHelper;
|
||||
|
||||
@ -27,6 +29,9 @@ import us.shandian.giga.io.FileStream;
|
||||
import us.shandian.giga.io.FileStreamSAF;
|
||||
|
||||
public class StoredFileHelper implements Serializable {
|
||||
private static final boolean DEBUG = MainActivity.DEBUG;
|
||||
private static final String TAG = StoredFileHelper.class.getSimpleName();
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
public static final String DEFAULT_MIME = "application/octet-stream";
|
||||
|
||||
@ -285,7 +290,13 @@ public class StoredFileHelper implements Serializable {
|
||||
}
|
||||
|
||||
public boolean existsAsFile() {
|
||||
if (source == null) {
|
||||
if (source == null || (docFile == null && ioFile == null)) {
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "existsAsFile called but something is null: source = ["
|
||||
+ (source == null ? "null => storage is invalid" : source)
|
||||
+ "], docFile = [" + (docFile == null ? "null" : docFile)
|
||||
+ "], ioFile = [" + (ioFile == null ? "null" : ioFile) + "]");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -664,7 +664,7 @@ public class DownloadMission extends Mission {
|
||||
* @return {@code true}, if storage is invalid and cannot be used
|
||||
*/
|
||||
public boolean hasInvalidStorage() {
|
||||
return errCode == ERROR_PROGRESS_LOST || storage == null || storage.isInvalid() || !storage.existsAsFile();
|
||||
return errCode == ERROR_PROGRESS_LOST || storage == null || !storage.existsAsFile();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user