Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ed658b8e
authored
Apr 10, 2015
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Attempt to guard against ExoCache corruption.
parent
cfcbca6c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
5 deletions
library/src/main/java/com/google/android/exoplayer/upstream/TeeDataSource.java
library/src/main/java/com/google/android/exoplayer/upstream/cache/CacheDataSink.java
library/src/main/java/com/google/android/exoplayer/util/Util.java
library/src/main/java/com/google/android/exoplayer/upstream/TeeDataSource.java
View file @
ed658b8e
...
...
@@ -61,8 +61,11 @@ public final class TeeDataSource implements DataSource {
@Override
public
void
close
()
throws
IOException
{
upstream
.
close
();
dataSink
.
close
();
try
{
upstream
.
close
();
}
finally
{
dataSink
.
close
();
}
}
}
library/src/main/java/com/google/android/exoplayer/upstream/cache/CacheDataSink.java
View file @
ed658b8e
...
...
@@ -19,6 +19,7 @@ import com.google.android.exoplayer.C;
import
com.google.android.exoplayer.upstream.DataSink
;
import
com.google.android.exoplayer.upstream.DataSpec
;
import
com.google.android.exoplayer.util.Assertions
;
import
com.google.android.exoplayer.util.Util
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
...
...
@@ -115,11 +116,23 @@ public class CacheDataSink implements DataSink {
}
private
void
closeCurrentOutputStream
()
throws
IOException
{
if
(
outputStream
!=
null
)
{
if
(
outputStream
==
null
)
{
return
;
}
boolean
success
=
false
;
try
{
outputStream
.
flush
();
outputStream
.
close
();
outputStream
.
getFD
().
sync
();
success
=
true
;
}
finally
{
Util
.
closeQuietly
(
outputStream
);
if
(
success
)
{
cache
.
commitFile
(
file
);
}
else
{
file
.
delete
();
}
outputStream
=
null
;
cache
.
commitFile
(
file
);
file
=
null
;
}
}
...
...
library/src/main/java/com/google/android/exoplayer/util/Util.java
View file @
ed658b8e
...
...
@@ -22,6 +22,7 @@ import android.text.TextUtils;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.OutputStream
;
import
java.lang.reflect.Method
;
import
java.math.BigDecimal
;
import
java.net.HttpURLConnection
;
...
...
@@ -130,6 +131,19 @@ public final class Util {
}
/**
* Closes an {@link OutputStream}, suppressing any {@link IOException} that may occur.
*
* @param outputStream The {@link OutputStream} to close.
*/
public
static
void
closeQuietly
(
OutputStream
outputStream
)
{
try
{
outputStream
.
close
();
}
catch
(
IOException
e
)
{
// Ignore.
}
}
/**
* Converts text to lower case using {@link Locale#US}.
*
* @param text The text to convert.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment