dordnung / System2

System2 Extension for Sourcemod
59 stars 16 forks source link

FTP Upload Stalling at Specific Number #10

Closed PhlexPlexico closed 5 years ago

PhlexPlexico commented 5 years ago

Hi,

It seems I'm running into an issue when trying to upload to an FTP server. Whenever I finish recording a demo, I want my plugin to upload it to a given server, but for some reason, it keeps stalling when the current uploaded bytes reach 131072. My code here is as shown, am I doing everything right?

...
    LogDebug("Sent our request!");
    System2FTPRequest ftpRequest = new System2FTPRequest(FtpResponseCallback, remoteDemoPath);
    ftpRequest.AppendToFile = true;
    ftpRequest.CreateMissingDirs = true;
    ftpRequest.SetAuthentication(g_FTPUsername, g_FTPPassword);
    ftpRequest.SetPort(g_FTPPort);
    ftpRequest.SetProgressCallback(FtpProgressCallback);
    ftpRequest.SetInputFile(filename);
    ftpRequest.StartRequest(); 
  } else{
    LogMessage("FTP Uploads Disabled OR Filename was empty (no demo to upload). Change config to enable.");
  }

public void FtpProgressCallback(System2FTPRequest request, int dlTotal, int dlNow, int ulTotal, int ulNow) {
  char file[PLATFORM_MAX_PATH];
  request.GetInputFile(file, sizeof(file));

  if (strlen(file) > 0) {
      PrintToServer("Uploading %s file with %d bytes total, %d now", file, ulTotal, ulNow);
  }
}  

public void FtpResponseCallback(bool success, const char[] error, System2FTPRequest request, System2FTPResponse response) {
    if (success) {
        char file[PLATFORM_MAX_PATH];
        request.GetInputFile(file, sizeof(file));

        if (strlen(file) > 0) {
            LogMessage("Delete file after complete.");
        }
    }
}  

And the output I get from the progress is the following:

Uploading demos/41_map1_de_mirage.dem file with 589824 bytes total, 0 now
Uploading demos/41_map1_de_mirage.dem file with 589824 bytes total, 131072 now
Uploading demos/41_map1_de_mirage.dem file with 589824 bytes total, 131072 now
Uploading demos/41_map1_de_mirage.dem file with 589824 bytes total, 131072 now

Followed by nothing else. Any idea as to why it's stalling? Thanks!

PhlexPlexico commented 5 years ago

Scratch that, just may be an issue with my FTP host. Tried with another and it seemed to upload just fine!