fix: delete old release attachments

This commit is contained in:
Akkuman
2025-06-23 15:10:15 +08:00
parent f119011bd6
commit 65a502e85c
2 changed files with 8 additions and 0 deletions

4
dist/index.js vendored
View File

@ -48278,6 +48278,7 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
repo: repo, repo: repo,
id: release_id, id: release_id,
}) })
// deleted old release attachment
for (const filepath of all_files) { for (const filepath of all_files) {
for (const attachment of attachments) { for (const attachment of attachments) {
let will_deleted = [external_path_.basename(filepath), `${external_path_.basename(filepath)}.md5`, `${external_path_.basename(filepath)}.sha256`] let will_deleted = [external_path_.basename(filepath), `${external_path_.basename(filepath)}.md5`, `${external_path_.basename(filepath)}.sha256`]
@ -48291,6 +48292,9 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
console.log(`Successfully deleted old release attachment ${attachment.name}`) console.log(`Successfully deleted old release attachment ${attachment.name}`)
} }
} }
}
// upload new release attachment
for (const filepath of all_files) {
const content = external_fs_.readFileSync(filepath); const content = external_fs_.readFileSync(filepath);
let blob = new external_buffer_.Blob([content]); let blob = new external_buffer_.Blob([content]);
await client.repository.repoCreateReleaseAttachment({ await client.repository.repoCreateReleaseAttachment({

View File

@ -142,6 +142,7 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
repo: repo, repo: repo,
id: release_id, id: release_id,
}) })
// deleted old release attachment
for (const filepath of all_files) { for (const filepath of all_files) {
for (const attachment of attachments) { for (const attachment of attachments) {
let will_deleted = [path.basename(filepath), `${path.basename(filepath)}.md5`, `${path.basename(filepath)}.sha256`] let will_deleted = [path.basename(filepath), `${path.basename(filepath)}.md5`, `${path.basename(filepath)}.sha256`]
@ -155,6 +156,9 @@ async function uploadFiles(client, owner, repo, release_id, all_files, params) {
console.log(`Successfully deleted old release attachment ${attachment.name}`) console.log(`Successfully deleted old release attachment ${attachment.name}`)
} }
} }
}
// upload new release attachment
for (const filepath of all_files) {
const content = fs.readFileSync(filepath); const content = fs.readFileSync(filepath);
let blob = new Blob([content]); let blob = new Blob([content]);
await client.repository.repoCreateReleaseAttachment({ await client.repository.repoCreateReleaseAttachment({