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)

1  
please include function dm_sendFileToOtherMachine. // for chunkSize
2  
3  
svoid dm_retrieveFileFromOtherMachine(S computerID, S remotePath, File f) {
4  
  backupFile(f);
5  
  
6  
  long size = toLong(dm_evalOnOtherMachine(computerID, "fileSizeOrMinus1(fileRelativeToUserDir(" + quote(remotePath) + "))");
7  
  if (size < 0) {
8  
    if (f.exists())
9  
      print("Deleting file: " + f);
10  
    ret;
11  
  }
12  
13  
  for (LongRange r : chunks(size, dm_sendFileToOtherMachine_chunkSize)) {
14  
    print("Retrieving file chunk " + r + " of " + computerID + ":" + remotePath + " to " + f);
15  
    byte[] chunk = cast dm_evalOnOtherMachine(computerID, "loadBinaryFileChunk(fileRelativeToUserDir(" + quote(remotePath) + "), " + r.start + "L, " + r.length() + ")");
16  
    saveBinaryFilePart(f, r.start, chunk);
17  
  }
18  
  
19  
  truncateFile(f, size);
20  
  print("File retrieved: " + f);
21  
}

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: 298 / 354
Version history: 13 change(s)
Referenced in: [show references]