mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-24 09:00:31 +00:00
Merge pull request #1407 from DafabHoid/dev
Downloader: Fix crash on loading unfinished downloads from .giga files
This commit is contained in:
commit
f4a9ec15e8
@ -5,6 +5,7 @@ import android.os.Looper;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -312,6 +313,13 @@ public class DownloadMission implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void readObject(ObjectInputStream inputStream)
|
||||||
|
throws java.io.IOException, ClassNotFoundException
|
||||||
|
{
|
||||||
|
inputStream.defaultReadObject();
|
||||||
|
mListeners = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
private void deleteThisFromFile() {
|
private void deleteThisFromFile() {
|
||||||
new File(getMetaFilename()).delete();
|
new File(getMetaFilename()).delete();
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import android.widget.Toast;
|
|||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
@ -59,12 +60,11 @@ public class Utility {
|
|||||||
ObjectOutputStream objectOutputStream = null;
|
ObjectOutputStream objectOutputStream = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
objectOutputStream = new ObjectOutputStream(new FileOutputStream(fileName));
|
objectOutputStream = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(fileName)));
|
||||||
objectOutputStream.writeObject(serializable);
|
objectOutputStream.writeObject(serializable);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//nothing to do
|
//nothing to do
|
||||||
}
|
} finally {
|
||||||
|
|
||||||
if(objectOutputStream != null) {
|
if(objectOutputStream != null) {
|
||||||
try {
|
try {
|
||||||
objectOutputStream.close();
|
objectOutputStream.close();
|
||||||
@ -73,6 +73,7 @@ public class Utility {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
Loading…
Reference in New Issue
Block a user