Closed T-vK closed 7 years ago
Thanks for your contribution!
i believe that it's not required to write any data to the file in case it is empty. open..close
should create it.
./nodemcu-tool terminal
[SerialTerminal] Starting Terminal Mode - press ctrl+c to exit
> file.open("x.lua", "w+")
> file.close()
> [SerialTerminal] Connection closed
./nodemcu-tool fsinfo
[NodeMCU-Tool] Connected
[NodeMCU] Version: 2.0.0 | ChipID: 0xd1aa | FlashID: 0x1640e0
[NodeMCU] Free Disk Space: 3265 KB | Total: 3366 KB | 14 Files
[NodeMCU] Files stored into Flash (SPIFFS)
|- f1.lua (18 Bytes)
|- f3.lua (19 Bytes)
|- f2.lua (19 Bytes)
|- x.lua (0 Bytes)
Well, initially I tried that, but I ended up with:
[NodeMCU-Tool] Uploading "e.lua" >> "e.lua"...
[NodeMCU-Connector] Transfer-Mode: hex
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1% | ETA: undefineds | 1/100[NodeMCU-Tool] File Transfer complete!
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 1% | ETA: nulls | 1/100
I assumed it failed.
But now that you mention it, I think you are probably right. I think we just have to ensure the callback is called even when the chunk
is empty. I'll make some adjustments and push another commit.
Seems to work pretty well. Empty files can be uploaded without additional writes and the download works without any issues, too.
nodemcu-tool upload g.lua
[NodeMCU-Tool] Project based configuration loaded
[NodeMCU-Tool] Connected
[NodeMCU] Version: 2.0.0 | ChipID: 0x1676b1 | FlashID: 0x1640e0
[NodeMCU-Tool] Uploading "g.lua" >> "g.lua"...
[NodeMCU-Connector] Transfer-Mode: hex
[NodeMCU-Tool] File Transfer complete!nodemcu-tool download g.lua
[NodeMCU-Tool] Project based configuration loaded
[NodeMCU-Tool] Local file "g.lua" already exist - new file renamed to "g.lua.1493478143226"
[NodeMCU-Tool] Connected
[NodeMCU] Version: 2.0.0 | ChipID: 0x1676b1 | FlashID: 0x1640e0
[NodeMCU-Tool] Downloading "g.lua" ...
[NodeMCU-Connector] Transfer-Encoding: base64
[NodeMCU-Tool] Data Transfer complete!
[NodeMCU-Tool] File "g.lua.1493478143226" created
Great :) v2.1.1 is out inlcuding your fix - thank you!
I fixed the issue by doing an initial empty write. This ensures that the file will be created even if it's empty. I also made sure that
chunks
will have a length property by making it an empty array if the file is empty.