cordova-promise-fs
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -172,17 +172,20 @@ var CordovaPromiseFS = | ||
var type = options.persistent? 1: 0; | ||
if(options.fileSystem){ | ||
if(options.fileSystem && isCordova){ | ||
type = options.fileSystem; | ||
} | ||
// Chrome only supports persistent and temp storage, not the exotic onces from Cordova | ||
if(!isCordova && type > 1) { | ||
console.warn('Chrome does not support fileSystem "'+type+'". Falling back on "0" (temporary).'); | ||
type = 0; | ||
// On chrome, request quota to store persistent files | ||
if (!isCordova && type === 1 && navigator.webkitPersistentStorage) { | ||
navigator.webkitPersistentStorage.requestQuota(options.storageSize, function(grantedBytes) { | ||
window.requestFileSystem(type, grantedBytes, resolve, reject); | ||
}); | ||
} | ||
if(isNaN(type)) { | ||
window.resolveLocalFileSystemURL(type,function(directory){ | ||
resolve(directory.filesystem); | ||
},reject); | ||
}else{ | ||
window.requestFileSystem(type, options.storageSize, resolve, reject); | ||
} | ||
// Exotic Cordova Directories (options.fileSystem = string) | ||
if(isNaN(type)) { | ||
window.resolveLocalFileSystemURL(type,function(directory){ | ||
resolve(directory.filesystem); | ||
},reject); | ||
// Normal browser usage | ||
} else { | ||
window.requestFileSystem(type, options.storageSize, resolve, reject); | ||
} | ||
@@ -189,0 +192,0 @@ setTimeout(function(){ reject(new Error('Could not retrieve FileSystem after 5 seconds.')); },5100); |
27
index.js
@@ -125,17 +125,20 @@ /** | ||
var type = options.persistent? 1: 0; | ||
if(options.fileSystem){ | ||
if(options.fileSystem && isCordova){ | ||
type = options.fileSystem; | ||
} | ||
// Chrome only supports persistent and temp storage, not the exotic onces from Cordova | ||
if(!isCordova && type > 1) { | ||
console.warn('Chrome does not support fileSystem "'+type+'". Falling back on "0" (temporary).'); | ||
type = 0; | ||
// On chrome, request quota to store persistent files | ||
if (!isCordova && type === 1 && navigator.webkitPersistentStorage) { | ||
navigator.webkitPersistentStorage.requestQuota(options.storageSize, function(grantedBytes) { | ||
window.requestFileSystem(type, grantedBytes, resolve, reject); | ||
}); | ||
} | ||
if(isNaN(type)) { | ||
window.resolveLocalFileSystemURL(type,function(directory){ | ||
resolve(directory.filesystem); | ||
},reject); | ||
}else{ | ||
window.requestFileSystem(type, options.storageSize, resolve, reject); | ||
} | ||
// Exotic Cordova Directories (options.fileSystem = string) | ||
if(isNaN(type)) { | ||
window.resolveLocalFileSystemURL(type,function(directory){ | ||
resolve(directory.filesystem); | ||
},reject); | ||
// Normal browser usage | ||
} else { | ||
window.requestFileSystem(type, options.storageSize, resolve, reject); | ||
} | ||
@@ -142,0 +145,0 @@ setTimeout(function(){ reject(new Error('Could not retrieve FileSystem after 5 seconds.')); },5100); |
{ | ||
"name": "cordova-promise-fs", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Cordova FileSystem convienence functions that return promises.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
128849
12
3814