Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

Commit

Permalink
Fix blob.slice unnecessary warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
wkh237 committed Aug 29, 2016
1 parent 23613d8 commit 81bdb0e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/polyfill/Blob.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ export default class Blob extends EventTarget {
* @param {any} data Content of Blob object
* @param {any} mime Content type settings of Blob object, `text/plain`
* by default
* @param {boolean} defer When this argument set to `true`, blob constructor
* will not invoke blob created event automatically.
*/
constructor(data:any, cType:any) {
constructor(data:any, cType:any, defer:boolean) {
super()
cType = cType || {}
this.cacheName = getBlobName()
Expand All @@ -75,6 +77,7 @@ export default class Blob extends EventTarget {
let size = 0
this._ref = String(data.getRNFetchBlobRef())
let orgPath = this._ref

p = fs.exists(orgPath)
.then((exist) => {
if(exist)
Expand Down Expand Up @@ -121,10 +124,14 @@ export default class Blob extends EventTarget {
log.verbose('create Blob cache file from file path', data)
this._ref = String(data).replace('RNFetchBlob-file://', '')
let orgPath = this._ref
p = fs.stat(orgPath)
.then((stat) => {
if(defer)
return
else {
p = fs.stat(orgPath)
.then((stat) => {
return Promise.resolve(stat.size)
})
})
}
}
// content from variable need create file
else if(typeof data === 'string') {
Expand Down Expand Up @@ -217,7 +224,7 @@ export default class Blob extends EventTarget {
let resPath = blobCacheDir + getBlobName()
let pass = false
log.debug('fs.slice new blob will at', resPath)
let result = new Blob(RNFetchBlob.wrap(resPath), { type : contentType })
let result = new Blob(RNFetchBlob.wrap(resPath), { type : contentType }, true)
fs.slice(this._ref, resPath, start, end).then((dest) => {
log.debug('fs.slice done', dest)
result._invokeOnCreateEvent()
Expand Down

0 comments on commit 81bdb0e

Please sign in to comment.