Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue #36 (Uploading empty files) #37

Merged
merged 2 commits into from Apr 29, 2017
Merged

Fixed issue #36 (Uploading empty files) #37

merged 2 commits into from Apr 29, 2017

Conversation

T-vK
Copy link
Contributor

@T-vK T-vK commented Apr 29, 2017

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.

@AndiDittrich
Copy link
Owner

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)

@T-vK
Copy link
Contributor Author

T-vK commented Apr 29, 2017

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.

@T-vK
Copy link
Contributor Author

T-vK commented Apr 29, 2017

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

@AndiDittrich AndiDittrich merged commit 76c8e12 into AndiDittrich:master Apr 29, 2017
AndiDittrich added a commit that referenced this pull request Apr 29, 2017
@AndiDittrich
Copy link
Owner

Great :) v2.1.1 is out inlcuding your fix - thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants