Simplify upload dialog to not upload directly

This commit is contained in:
Silvano Cerza 2025-01-11 17:08:11 +01:00
parent 176c52b68a
commit 6bff97ace2

View file

@ -121,25 +121,10 @@ const UploadDialogContent = ({ onCancel }: { onCancel: () => void }) => {
if (abortController.signal.aborted) {
return;
}
await plugin.client.uploadFile(
plugin.settings.githubOwner,
plugin.settings.githubRepo,
plugin.settings.githubBranch,
file.path,
);
// Reset dirty state
plugin.metadataStore.data[file.path].dirty = false;
// Gets the new SHA of the file
const sha = await plugin.client.getFileSha(
plugin.settings.githubOwner,
plugin.settings.githubRepo,
plugin.settings.githubBranch,
file.path,
);
plugin.metadataStore.data[file.path].sha = sha;
await plugin.metadataStore.save();
await plugin.eventsConsumer.process({
type: "modify",
filePath: file.path,
});
if (abortController.signal.aborted) {
// Check abort state only after the uploaded file metadata
// is updated, otherwise we risk having outdated SHAs