Skip to content

Commit

Permalink
Merge pull request #33 from d0rich/main
Browse files Browse the repository at this point in the history
Catch known but not downloaded file situation
  • Loading branch information
d0rich authored Nov 4, 2023
2 parents a07480d + 248df99 commit f2b07bf
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 f2b07bf

Please sign in to comment.