Skip to content

Commit

Permalink
Catch known but not downloaded file situation
Browse files Browse the repository at this point in the history
  • Loading branch information
d0rich committed Nov 4, 2023
1 parent 9b4251a commit b7ecbcc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ton-drive-backend/src/ton-storage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,15 @@ export class TonStorageService {
try {
const cliRes = await this.execCliCommand(`\"get ${bagId} --json\"`)
const cliResParsed = JSON.parse(cliRes);

const noSuchTorrent = cliRes.match(/.+No such torrent/) !== null;
const knownButNotDownloaded = cliResParsed["torrent"]?.downloaded_size === '0';
// if bag not found, try to add it
if (cliRes.match(/.+No such torrent/) !== null) {
if (noSuchTorrent || knownButNotDownloaded) {
const output = await this.execCliCommand(`\"add-by-hash ${bagId}\"`)
return {
ready: false,
exists: false,
exists: knownButNotDownloaded,
_output: output
}
}
Expand Down

0 comments on commit b7ecbcc

Please sign in to comment.