Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
bower_components
bower_components
.idea
3 changes: 1 addition & 2 deletions demos/basic/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ function writeFile(file, i) {
};
fileWriter.onwriteend = function() {
console.log('WRITE END');
getAllEntries(cwd);
};
fileWriter.write(file);
}, onError);

getAllEntries(cwd);
}, onError);
}

Expand Down
33 changes: 18 additions & 15 deletions src/idb.filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ if (exports.requestFileSystem || exports.webkitRequestFileSystem) {
}

// Bomb out if no indexedDB available
const indexedDB = exports.indexedDB || exports.mozIndexedDB ||
var indexedDB = exports.indexedDB || exports.mozIndexedDB ||
exports.msIndexedDB;
if (!indexedDB) {
return;
}

let IDB_SUPPORTS_BLOB = true;
var IDB_SUPPORTS_BLOB = false;
Copy link
Owner

@ebidel ebidel Sep 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't need to switch over the const/lets. The src goes through closure which produces ES5. Please revert those changes.

Copy link
Author

@vheun vheun Sep 16, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love led and const, but it seems to not make a difference in this project and some people (like me) like to use the not minified files in the project development process, which then would produce an error.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most modern browsers support let/const out of the box and it's only a matter of time before Safari 10 supports both. I'd also like to move to full es6 support eventually so it's more important that the untransformed source be easier to maintain.

Copy link
Author

@vheun vheun Sep 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But isn't the idea of this work to make filesystem API accessible for (older) browsers that do not support filesystem API? Chrome has it and firefox starts to support it. Its Safari that profits most. The advantages available for led and const are not that big to make a file incompatible with the purpose it should surf. I don't want to be rude. Its an amazing project. I understand the wish to run with the latest standards and I would love to use let in all my projects as well cause it would save me from a lot of overhead, but I kind of disagree with the choice in this case.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The transpired file that's in dist/ works in all browsers. Put it this way, if this source was written in .ts or .coffee, it would require transpilation to run in older browsers. The same is currently true for es6 features. Ultimately, it doesn't matter how the source is written because we're now providing a built file.



// Check to see if IndexedDB support blobs
const support = function() {
function setSupportsBlob() {
var dbName = "blob-support";
indexedDB.deleteDatabase(dbName).onsuccess = function() {
var request = indexedDB.open(dbName, 1);
Expand All @@ -70,7 +71,9 @@ const support = function() {
};
};

const Base64ToBlob = function(dataURL) {
setSupportsBlob();

function Base64ToBlob(dataURL) {
var BASE64_MARKER = ';base64,';
if (dataURL.indexOf(BASE64_MARKER) == -1) {
var parts = dataURL.split(',');
Expand All @@ -94,7 +97,7 @@ const Base64ToBlob = function(dataURL) {
return new Blob([uInt8Array], {type: contentType});
};

const BlobToBase64 = function(blob, onload) {
function BlobToBase64(blob, onload) {
var reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = function() {
Expand Down Expand Up @@ -146,24 +149,24 @@ function MyFileError(obj) {
MyFileError.prototype = FileError.prototype;
MyFileError.prototype.toString = Error.prototype.toString;

const INVALID_MODIFICATION_ERR = new MyFileError({
var INVALID_MODIFICATION_ERR = new MyFileError({
code: FileError.INVALID_MODIFICATION_ERR,
name: 'INVALID_MODIFICATION_ERR'});
const NOT_IMPLEMENTED_ERR = new MyFileError({code: 1000,
var NOT_IMPLEMENTED_ERR = new MyFileError({code: 1000,
name: 'Not implemented'});
const NOT_FOUND_ERR = new MyFileError({code: FileError.NOT_FOUND_ERR,
var NOT_FOUND_ERR = new MyFileError({code: FileError.NOT_FOUND_ERR,
name: 'Not found'});

let fs_ = null;
var fs_ = null;

// Browsers other than Chrome don't implement persistent vs. temporary storage.
// but default to temporary anyway.
let storageType_ = 'temporary';
const idb_ = {db: null};
const FILE_STORE_ = 'entries';
var storageType_ = 'temporary';
var idb_ = {db: null};
var FILE_STORE_ = 'entries';

const DIR_SEPARATOR = '/';
const DIR_OPEN_BOUND = String.fromCharCode(DIR_SEPARATOR.charCodeAt(0) + 1);
var DIR_SEPARATOR = '/';
var DIR_OPEN_BOUND = String.fromCharCode(DIR_SEPARATOR.charCodeAt(0) + 1);

// When saving an entry, the fullPath should always lead with a slash and never
// end with one (e.g. a directory). Also, resolve '.' and '..' to an absolute
Expand Down Expand Up @@ -342,7 +345,7 @@ function FileWriter(fileEntry) {
blob_ = new Blob([data], {type: data.type});
}

const writeFile = function(blob) {
var writeFile = function(blob) {
// Blob might be a DataURI depending on browser support.
fileEntry.file_.blob_ = blob;
fileEntry.file_.lastModifiedDate = data.lastModifiedDate || new Date();
Expand Down