You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-29 22:48:10 +02:00
All: Better handling of resource download errors, and added resource info to sync status screen
This commit is contained in:
@@ -5,6 +5,8 @@ const Folder = require('lib/models/Folder.js');
|
||||
const Note = require('lib/models/Note.js');
|
||||
const BaseModel = require('lib/BaseModel.js');
|
||||
const DecryptionWorker = require('lib/services/DecryptionWorker');
|
||||
const ResourceFetcher = require('lib/services/ResourceFetcher');
|
||||
const Resource = require('lib/models/Resource');
|
||||
const { _ } = require('lib/locale.js');
|
||||
const { toTitleCase } = require('lib/string-utils.js');
|
||||
|
||||
@@ -158,6 +160,46 @@ class ReportService {
|
||||
sections.push(section);
|
||||
}
|
||||
|
||||
{
|
||||
section = { title: _('Attachments'), body: [], name: 'resources' };
|
||||
|
||||
const statuses = [Resource.FETCH_STATUS_IDLE, Resource.FETCH_STATUS_STARTED, Resource.FETCH_STATUS_DONE, Resource.FETCH_STATUS_ERROR];
|
||||
|
||||
for (const status of statuses) {
|
||||
if (status === Resource.FETCH_STATUS_DONE) {
|
||||
const downloadedButEncryptedBlobCount = await Resource.downloadedButEncryptedBlobCount();
|
||||
const downloadedCount = await Resource.downloadStatusCounts(Resource.FETCH_STATUS_DONE);
|
||||
section.body.push(_('%s: %d', _('Downloaded and decrypted'), downloadedCount - downloadedButEncryptedBlobCount));
|
||||
section.body.push(_('%s: %d', _('Downloaded and encrypted'), downloadedButEncryptedBlobCount));
|
||||
} else {
|
||||
const count = await Resource.downloadStatusCounts(status);
|
||||
section.body.push(_('%s: %d', Resource.fetchStatusToLabel(status), count));
|
||||
}
|
||||
}
|
||||
|
||||
sections.push(section);
|
||||
}
|
||||
|
||||
const resourceErrorFetchStatuses = await Resource.errorFetchStatuses();
|
||||
|
||||
if (resourceErrorFetchStatuses.length) {
|
||||
section = { title: _('Attachments that could not be downloaded'), body: [], name: 'failedResourceDownload' };
|
||||
|
||||
for (let i = 0; i < resourceErrorFetchStatuses.length; i++) {
|
||||
const row = resourceErrorFetchStatuses[i];
|
||||
section.body.push({
|
||||
text: _('%s (%s): %s', row.resource_title, row.resource_id, row.fetch_error),
|
||||
canRetry: true,
|
||||
retryHandler: async () => {
|
||||
await Resource.resetErrorStatus(row.resource_id);
|
||||
ResourceFetcher.instance().autoAddResources();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
sections.push(section);
|
||||
}
|
||||
|
||||
section = { title: _('Sync status (synced items / total items)'), body: [] };
|
||||
|
||||
for (let n in r.items) {
|
||||
|
||||
Reference in New Issue
Block a user