cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From za...@apache.org
Subject [1/2] git commit: Overwrite existing file on getFile when create is true
Date Wed, 27 Aug 2014 11:46:01 GMT
Repository: cordova-plugin-file
Updated Branches:
  refs/heads/master dd51229d9 -> ad05e3203


Overwrite existing file on getFile when create is true


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/e393c3cb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/e393c3cb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/e393c3cb

Branch: refs/heads/master
Commit: e393c3cbcb22475f58f03549bd5b52943a522946
Parents: 3086907
Author: Rodrigo Silveira <rodrigos@outlook.com>
Authored: Tue Aug 19 14:49:34 2014 -0700
Committer: Rodrigo Silveira <rodrigos@outlook.com>
Committed: Tue Aug 19 14:49:34 2014 -0700

----------------------------------------------------------------------
 src/firefoxos/FileProxy.js | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/e393c3cb/src/firefoxos/FileProxy.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/FileProxy.js b/src/firefoxos/FileProxy.js
index b4b5f1b..3662edc 100644
--- a/src/firefoxos/FileProxy.js
+++ b/src/firefoxos/FileProxy.js
@@ -136,7 +136,19 @@ QUIRKS:
                 idb_.put(newFileEntry, path.storagePath, successCallback, errorCallback);
             } else if (options.create === true && fileEntry) {
                 if (fileEntry.isFile) {
-                    successCallback(fileEntryFromIdbEntry(fileEntry));
+                    // Overwrite file, delete then create new.
+                    idb_['delete'](path.storagePath, function() {
+                        var newFileEntry = new FileEntry(path.fileName, path.fullPath, new
FileSystem(path.fsName, fs_.root));
+
+                        newFileEntry.file_ = new MyFile({
+                            size: 0,
+                            name: newFileEntry.name,
+                            lastModifiedDate: new Date(),
+                            storagePath: path.storagePath
+                        });
+
+                        idb_.put(newFileEntry, path.storagePath, successCallback, errorCallback);
+                    }, errorCallback);
                 } else {
                     if (errorCallback) {
                         errorCallback(FileError.INVALID_MODIFICATION_ERR);


Mime
View raw message