lihaibh / ditto

NPM library that helps managing MongoDB snapshots easily and efficiently
https://www.npmjs.com/package/mongodb-snapshot
MIT License
48 stars 6 forks source link

no/silent error on wrong dump-path #34

Open l1ghty opened 2 years ago

l1ghty commented 2 years ago

If the path for LocalFileSystemDuplexConnector is wrong a few lines with "remaining bytes to write" will appear. This makes it harder to spot the real problem.

Throwing a exception instead would be nice.

const mongo_connector = new MongoDBDuplexConnector({ connection: { // uri:mongodb://username>:<password>@<hostname:`, uri: envMongo.uri, // dbname: '', dbname: db, }, });

const localfile_connector = new LocalFileSystemDuplexConnector({ connection: { path: dumpFolder+'/'+ db +'/'+ db+'.tar', }, });

const transferer = new MongoTransferer({ source: mongo_connector, targets: [localfile_connector], });

for await (const { total, write } of transferer) { console.info(remaining bytes to write: ${total - write}); }`

lihaibh commented 2 years ago

@l1ghty well if the path is wrong you should use "try catch" around the for await. it will fail with the error information. You can also use transferer.toPromise() if you dont care about the progression of the transfer, just wish to await till completion

lihaibh commented 2 years ago

did your problem solved? @l1ghty