mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-03 04:31:46 +02:00
add a check on file upload
This commit is contained in:
@@ -93,9 +93,11 @@ async function uploadFile(filename, data, cancelToken) {
|
||||
});
|
||||
cancelToken.cancel = request.cancel;
|
||||
let response = await request;
|
||||
console.log(response.info().status);
|
||||
|
||||
let status = response.info().status;
|
||||
let result = status >= 200 && status < 300;
|
||||
let text = await response.text();
|
||||
|
||||
let result = status >= 200 && status < 300 && text.length === 0
|
||||
useAttachmentStore.getState().remove(filename);
|
||||
if (result) {
|
||||
let attachment = db.attachments.attachment(filename);
|
||||
@@ -146,6 +148,7 @@ async function downloadFile(filename, data, cancelToken) {
|
||||
|
||||
cancelToken.cancel = request.cancel;
|
||||
let response = await request;
|
||||
|
||||
let status = response.info().status;
|
||||
useAttachmentStore.getState().remove(filename);
|
||||
return status >= 200 && status < 300;
|
||||
|
||||
Reference in New Issue
Block a user