From 66504df4cbeed94dd3e746a0d965083772b0723a Mon Sep 17 00:00:00 2001 From: Mahdi Dibaiee Date: Mon, 14 Sep 2015 12:42:50 +0430 Subject: [PATCH] fix file.create: don't create an .empty folder on devices with new API support feat docs: add Frequently Asked Questions section --- README.md | 16 +++++++++++++++- build/main.js | 4 +++- build/polyfill.js | 3 +++ releases/hawk-1.0.0.zip | Bin 1245239 -> 1245329 bytes src/js/api/files.js | 4 +++- src/polyfill.js | 3 +++ 6 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e86a75c..606910f 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,25 @@ Firefox OS 2.2 and up are supported. Sadly 2.0 and 1.3 miss a lot of ES6 functio ![Mobile Portrait Mockup](https://github.com/mdibaiee/Hawk/raw/master/Mobile%20Portrait.png) -#Thanks to +# Thanks to Sergio Muriel [@tfeserver](https://twitter.com/tfeserver) for testing application Mohammad Jahani [@mamal72](https://twitter.com/mamal72) for ideas, and helping in designing the [webpage](http://dibaiee.ir/Hawk) +# Frequently Asked Questions + +**Q: Why does Hawk create an `.empty` file inside new folders I create?** + +This happens on Firefox OS devices below version 3, and that's because the API doesn't allow +listing empty folders, in order to show you the folder, Hawk has to fake the folder to have a child. + + +**Q: Why is Hawk slow?** + +Hawk is much faster on Firefox OS 3.0 and up, and that's because the way old Device Storage API works, +it's slow by nature. Nothing we can do about it, sadly. + + # Features Version 1.0 diff --git a/build/main.js b/build/main.js index bf7ca28..f9f12a2 100644 --- a/build/main.js +++ b/build/main.js @@ -30057,7 +30057,9 @@ var createDirectory = _asyncToGenerator(function* () { var parent = yield root(); return parent.createDirectory.apply(parent, args).then(function () { - return createFile(args[0] + '/.empty'); + if (window.needsShim) { + return createFile(args[0] + '/.empty'); + } }); }); diff --git a/build/polyfill.js b/build/polyfill.js index 1a2bdab..f5fd5aa 100644 --- a/build/polyfill.js +++ b/build/polyfill.js @@ -21,8 +21,11 @@ function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPr }; }(Element.prototype)); +window.needsShim = false; + function shimDirectory(directory) { if (!directory.getFilesAndDirectories) { + window.needsShim = true; directory.toString = function() { return '[object Directory]' }; directory.getFilesAndDirectories = function getFilesAndDirectories() { var current = (this.path || '') + this.name; diff --git a/releases/hawk-1.0.0.zip b/releases/hawk-1.0.0.zip index 84da1a21a7ec552b541d45d9a1fd62d092cfafa4..c07b17830603a6c8063a8e9aa48b2eaabb25d28b 100644 GIT binary patch delta 691 zcmdnq;4`t&hbO?BnT3l11oToS@+dL^Nqq$%xiN5?5s=!7sRj&V|>UCVkpKjzU2Th1kxG1SV4?AIgE*5#{WXbbWV^+Mm6Id zCJ@7|j!_n@E47vJD+@>@ri;-AY~ZZvjQ7FjR4-ucVC2;Ar5UI zWBS`)LWUq(;kS?hhz|NKWDBAv{uZ(U(dVHw?;i-?`;U+%NWATjkQInN^arAz@vo2t zh;I$0OQH1oze3g^@i%`V>NWmB=oBcu;2*@i+y5Z?MgI$#p$7f*i2p(w@}SsQ63O&M zpN)Y5g!#cq2u8$DpZ{M-4y*_sUcfNphRK8J-P7;<7m@-w=Er{_8D+x@LJY+vl{u+; a$;HJ1-mE}F85qQY(213S!Sc5dkOu(B<<%bm delta 616 zcmbQ(=(D}ShbO?BnT3l11pI|2@+dL^Nqq$%xiN5?5s=!7sRj&V|>UCVkpKjzU2Th1kxG1SV4?AIgE*5#{WXbbWV^+Mm6Id zCJ@7|j!_n@E47vJD+@>@ri;-AY~ZZvjQ7FjR4-ucVC3}|(sN%Bl2$9*&d(s*F0hCZ zh?#(x8Hibcm=%cGfS4VKIe?fGh`E568;E&;m=}oowhJucmlvHLSIf^nJ!Ct-@^rJU z{DSR$+xfTmZ5Oy*2(mw0Q!t7RY}+)w@GasC7#YOdFX;ZAV(S%COcq4aqu&G}Er8YJ%a52C&aO7DZxzy3kYGyM*+uL3&}--!W8aHpijBM2?0h-*B4|c$j_-v%go8q%PJ1=W@Hj!fTa~Z g_o+%nhaYM&Fn};8Ob?j8etv3!ur%BKUqV1G0JDd;)&Kwi diff --git a/src/js/api/files.js b/src/js/api/files.js index b7a8b31..cfe0a07 100644 --- a/src/js/api/files.js +++ b/src/js/api/files.js @@ -84,7 +84,9 @@ export async function createDirectory(...args) { let parent = await root(); return parent.createDirectory(...args).then(() => { - return createFile(args[0] + '/.empty'); + if (window.needsShim) { + return createFile(args[0] + '/.empty'); + } }); } diff --git a/src/polyfill.js b/src/polyfill.js index 1a2bdab..f5fd5aa 100644 --- a/src/polyfill.js +++ b/src/polyfill.js @@ -21,8 +21,11 @@ function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPr }; }(Element.prototype)); +window.needsShim = false; + function shimDirectory(directory) { if (!directory.getFilesAndDirectories) { + window.needsShim = true; directory.toString = function() { return '[object Directory]' }; directory.getFilesAndDirectories = function getFilesAndDirectories() { var current = (this.path || '') + this.name;