You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-15 23:00:36 +02:00
Mobile: Added support for ResourceFetcher service
This commit is contained in:
@ -80,8 +80,21 @@ class ResourceFetcher extends BaseService {
|
||||
if (this.fetchingItems_[resourceId]) return;
|
||||
this.fetchingItems_[resourceId] = true;
|
||||
|
||||
const completeDownload = (emitDownloadComplete = true) => {
|
||||
delete this.fetchingItems_[resource.id];
|
||||
this.scheduleQueueProcess();
|
||||
if (emitDownloadComplete) this.eventEmitter_.emit('downloadComplete', { id: resource.id });
|
||||
}
|
||||
|
||||
const resource = await Resource.load(resourceId);
|
||||
|
||||
// Shouldn't happen, but just to be safe don't re-download the
|
||||
// resource if it's already been downloaded.
|
||||
if (resource.fetch_status === Resource.FETCH_STATUS_DONE) {
|
||||
completeDownload(false);
|
||||
return;
|
||||
}
|
||||
|
||||
this.fetchingItems_[resourceId] = resource;
|
||||
|
||||
const localResourceContentPath = Resource.fullPath(resource);
|
||||
@ -93,12 +106,6 @@ class ResourceFetcher extends BaseService {
|
||||
|
||||
this.logger().debug('ResourceFetcher: Downloading resource: ' + resource.id);
|
||||
|
||||
const completeDownload = () => {
|
||||
delete this.fetchingItems_[resource.id];
|
||||
this.scheduleQueueProcess();
|
||||
this.eventEmitter_.emit('downloadComplete', { id: resource.id });
|
||||
}
|
||||
|
||||
fileApi.get(remoteResourceContentPath, { path: localResourceContentPath, target: "file" }).then(async () => {
|
||||
await Resource.saveFetchStatus(resource.id, Resource.FETCH_STATUS_DONE);
|
||||
this.logger().debug('ResourceFetcher: Resource downloaded: ' + resource.id);
|
||||
|
Reference in New Issue
Block a user