Skip to content

Commit

Permalink
Fixes transferStatus being uncallable, adds locationSummary
Browse files Browse the repository at this point in the history
  • Loading branch information
Spoffy committed Jan 20, 2025
1 parent 761d351 commit 4b733b3
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions app/server/lib/DocApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,27 @@ export class DocWorkerApi {
res.json({records});
}));

// Starts transferring all attachments to the named store, if it exists.
this._app.post('/api/docs/:docId/attachments/transferAll', isOwner, withDoc(async (activeDoc, req, res) => {
await activeDoc.startTransferringAllAttachmentsToDefaultStore();
const locationSummary = await activeDoc.attachmentLocationSummary();

// Respond with the current status to allow for immediate UI updates.
res.json({
status: activeDoc.attachmentTransferStatus(),
locationSummary,
});
}));

// Returns the status of any current / pending attachment transfers
this._app.get('/api/docs/:docId/attachments/transferStatus', isOwner, withDoc(async (activeDoc, req, res) => {
const locationSummary = await activeDoc.attachmentLocationSummary();
res.json({
status: activeDoc.attachmentTransferStatus(),
locationSummary,
});
}));

// Returns cleaned metadata for a given attachment ID (i.e. a rowId in _grist_Attachments table).
this._app.get('/api/docs/:docId/attachments/:attId', canView, withDoc(async (activeDoc, req, res) => {
const attId = integerParam(req.params.attId, 'attId');
Expand Down Expand Up @@ -548,25 +569,6 @@ export class DocWorkerApi {
.send(fileData);
}));

// Starts transferring all attachments to the named store, if it exists.
this._app.post('/api/docs/:docId/attachments/transferAll', isOwner, withDoc(async (activeDoc, req, res) => {
await activeDoc.startTransferringAllAttachmentsToDefaultStore();
const locationSummary = await activeDoc.attachmentLocationSummary();

// Respond with the current status to allow for immediate UI updates.
res.json({
status: activeDoc.attachmentTransferStatus(),
locationSummary,
});
}));

// Returns the status of any current / pending attachment transfers
this._app.get('/api/docs/:docId/attachments/transferStatus', isOwner, withDoc(async (activeDoc, req, res) => {
res.json({
status: activeDoc.attachmentTransferStatus(),
});
}));

// Mostly for testing
this._app.post('/api/docs/:docId/attachments/updateUsed', canEdit, withDoc(async (activeDoc, req, res) => {
await activeDoc.updateUsedAttachmentsIfNeeded();
Expand Down

0 comments on commit 4b733b3

Please sign in to comment.