meganz / MEGAcmd

Command Line Interactive and Scriptable Application to access MEGA
Other
1.95k stars 407 forks source link

MEGAclient.exe doesn't download file on first cold boot #143

Open joshirio opened 5 years ago

joshirio commented 5 years ago

MEGAcmd version: 1.0.0 Affected OS: tested on Windows 7 and Windows 10 (works fine on Linux)

MEGAcmd.exe (or mega-get.bat) doesn't download specified files when it is started for the first time (cold boot) after a system reboot. The output is Server not running. Initiating in the background... but then the program exits without any error yet the file is not downloaded.

Now it gets interesting because if you repeat the command again then it works and the file is downloaded, even if you kill the mega-cmd-server process. So this bug appears only on a cold boot.

How to reproduce:

  1. Login to your MEGA account through megacmd.
  2. Reboot your windows machine (a real reboot is required because fast startup in Windows 10 is not really shutting down completely the session state, so make sure you click reboot from the start menu)
  3. Download a file. For example, create a new directory on MEGA called Testwith just a test.txt file containing sample text and then download it by the following the next steps:
    1. open cmd.exe from the start menu
    2. go to the MEGAcmd directory with C:\Users\user\AppData\Local\MEGAcmd
    3. download your test file with MEGAclient.exe get Test/test.txt
    4. mega-cmd-server is strated in the background Server not running. Initiating in the background...
  4. You will notice that there will be no test.txt file in the MEGAcmd directory
  5. If you repeat the MEGAclient.exe get Test/test.txt command the file gets downloaded for real this time
  6. If you exit/kill the mega-cmd-server process and repeat the steps above it will work despite the server not running in background
  7. If you reboot again and start the mega-cmd-server manually first (by opening MEGAcmd from start menu) it will work fine because it will no longer be a cold boot when you run the megaclient.exe
polmr commented 5 years ago

Hi joshirio. thanks for reporting that. That's a really odd thing. I had been able to reproduced it once with a particularly slow Win 7, not in Win 10. It might be a time issue (the second time you initialize the server some disk reading might be cached and it being faster could solve the time issue). We will review the initialization process and see if there's something wrong. However, can you try to execute it with increased verbosity:

MEGAclient.exe get Test/test.txt -vvv

and see what is the output and if the issue persists in that case.

joshirio commented 5 years ago

Yes really odd because the other day I was able to reproduce this consistently every time on 2 machines. Today it works flawlessly, 🤔

C:\Users\user\AppData\Local\MEGAcmd>MEGAclient.exe get Symphytum/sync.meta -vvv
Server not running. Initiating in the background...
[API:debug: 11:13:38] Starting download: sync.meta to : \\?\C:\Users\user\AppDat
a\Local\MEGAcmd\
[API:verbose: 11:13:39]  Procesed get Symphytum/sync.meta -vvv \\?\C:\Users\user
\AppData\Local\MEGAcmd in thread: 3380 namedPipe output: 00000244
[API:verbose: 11:13:39] Output to write in namedPipe 00000244: <<[API:debug: 11:
13:38] Starting download: sync.meta to : \\?\C:\Users\user\AppData\Local\MEGAcmd
\
[API:verbose: 11:13:39]  Procesed get Symphytum/sync.meta -vvv \\?\C:\Users\user
\AppData\Local\MEGAcmd in thread: 3380 namedPipe output: 00000244
>>
[API:verbose: 11:13:39] Client arrived first when connecting to namedPipe 000002
44

C:\Users\user\AppData\Local\MEGAcmd>

Thanks for your response, I'll give it another try later to see if I am able to reproduce this.