You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
Desktop, Cli, Mobile: Display an error if a resource cannot be downloaded
This commit is contained in:
@@ -182,20 +182,18 @@ export default class ResourceFetcher extends BaseService {
|
|||||||
|
|
||||||
this.eventEmitter_.emit('downloadStarted', { id: resource.id });
|
this.eventEmitter_.emit('downloadStarted', { id: resource.id });
|
||||||
|
|
||||||
fileApi
|
try {
|
||||||
.get(remoteResourceContentPath, { path: localResourceContentPath, target: 'file' })
|
const response = await fileApi.get(remoteResourceContentPath, { path: localResourceContentPath, target: 'file' });
|
||||||
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
|
if (!response) throw new Error(`Resource not found: ${resource.id}`);
|
||||||
.then(async () => {
|
|
||||||
await Resource.setLocalState(resource, { fetch_status: Resource.FETCH_STATUS_DONE });
|
await Resource.setLocalState(resource, { fetch_status: Resource.FETCH_STATUS_DONE });
|
||||||
this.logger().debug(`ResourceFetcher: Resource downloaded: ${resource.id}`);
|
this.logger().debug(`ResourceFetcher: Resource downloaded: ${resource.id}`);
|
||||||
await completeDownload(true, localResourceContentPath);
|
await completeDownload(true, localResourceContentPath);
|
||||||
})
|
} catch (error) {
|
||||||
// eslint-disable-next-line promise/prefer-await-to-then -- Old code before rule was applied
|
this.logger().error(`ResourceFetcher: Could not download resource: ${resource.id}`, error);
|
||||||
.catch(async (error: any) => {
|
await Resource.setLocalState(resource, { fetch_status: Resource.FETCH_STATUS_ERROR, fetch_error: error.message });
|
||||||
this.logger().error(`ResourceFetcher: Could not download resource: ${resource.id}`, error);
|
await completeDownload();
|
||||||
await Resource.setLocalState(resource, { fetch_status: Resource.FETCH_STATUS_ERROR, fetch_error: error.message });
|
}
|
||||||
await completeDownload();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private processQueue_() {
|
private processQueue_() {
|
||||||
|
|||||||
Reference in New Issue
Block a user