Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

21
LINES

< > BotCompany Repo | #1020817 // dm_retrieveFileFromOtherMachine - also splits. warning: signed, but not encrypted. doesn't handle intermittent file updates

JavaX fragment (include)

please include function dm_sendFileToOtherMachine. // for chunkSize

svoid dm_retrieveFileFromOtherMachine(S computerID, S remotePath, File f) {
  backupFile(f);
  
  long size = toLong(dm_evalOnOtherMachine(computerID, "fileSizeOrMinus1(fileRelativeToUserDir(" + quote(remotePath) + "))");
  if (size < 0) {
    if (f.exists())
      print("Deleting file: " + f);
    ret;
  }

  for (LongRange r : chunks(size, dm_sendFileToOtherMachine_chunkSize)) {
    print("Retrieving file chunk " + r + " of " + computerID + ":" + remotePath + " to " + f);
    byte[] chunk = cast dm_evalOnOtherMachine(computerID, "loadBinaryFileChunk(fileRelativeToUserDir(" + quote(remotePath) + "), " + r.start + "L, " + r.length() + ")");
    saveBinaryFilePart(f, r.start, chunk);
  }
  
  truncateFile(f, size);
  print("File retrieved: " + f);
}

Author comment

Began life as a copy of #1020607

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1020817
Snippet name: dm_retrieveFileFromOtherMachine - also splits. warning: signed, but not encrypted. doesn't handle intermittent file updates
Eternal ID of this version: #1020817/14
Text MD5: 70607fb2ba0ea3274d32f5edde698fc9
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-10 09:32:29
Source code size: 847 bytes / 21 lines
Pitched / IR pitched: No / No
Views / Downloads: 297 / 353
Version history: 13 change(s)
Referenced in: [show references]