This repository was archived by the owner on Feb 6, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
library/src/main/java/com/opensource/svgaplayer Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ object SVGACache {
2323 if (isInitialized()) return
2424 context ? : return
2525 cacheDir = " ${context.cacheDir.absolutePath} /svga/"
26- File (cacheDir).takeIf { ! it.exists() }?.mkdir ()
26+ File (cacheDir).takeIf { ! it.exists() }?.mkdirs ()
2727 this .type = type
2828 }
2929
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import android.content.Context
44import android.net.http.HttpResponseCache
55import android.os.Handler
66import android.os.Looper
7+ import android.util.Log
78import com.opensource.svgaplayer.proto.MovieEntity
89import com.opensource.svgaplayer.utils.log.LogUtils
910import org.json.JSONObject
@@ -237,8 +238,13 @@ class SVGAParser(context: Context?) {
237238 readAsBytes(inputStream)?.let { bytes ->
238239 threadPoolExecutor.execute {
239240 SVGACache .buildSvgaFile(cacheKey).let { cacheFile ->
240- cacheFile.takeIf { ! it.exists() }?.createNewFile()
241- FileOutputStream (cacheFile).write(bytes)
241+ try {
242+ cacheFile.takeIf { ! it.exists() }?.createNewFile()
243+ FileOutputStream (cacheFile).write(bytes)
244+ } catch (e: Exception ) {
245+ LogUtils .error(TAG , " create cache file fail." , e)
246+ cacheFile.delete()
247+ }
242248 }
243249 }
244250 LogUtils .info(TAG , " Input.inflate start" )
You can’t perform that action at this time.
0 commit comments