Skip to content

Commit

Permalink
fix(git): Clean up locks
Browse files Browse the repository at this point in the history
Signed-off-by: Marcel Klehr <[email protected]>
  • Loading branch information
marcelklehr committed Jan 14, 2024
1 parent 0ccc2dc commit 527c25f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/lib/adapters/Git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const LOCK_INTERVAL = 2 * 60 * 1000 // Lock every 2mins while syncing
const LOCK_TIMEOUT = 15 * 60 * 1000 // Override lock 0.25h after last time lock has been set
export default class GitAdapter extends CachingAdapter {
private lockingInterval: any
private locked: string | false
private locked: string[]
private cancelCallback: () => void
private initialTreeHash: string
private dir: string
Expand All @@ -39,7 +39,7 @@ export default class GitAdapter extends CachingAdapter {
constructor(server) {
super(server)
this.server = server
this.locked = false
this.locked = []
this.lockingInterval = null
}

Expand Down Expand Up @@ -239,22 +239,20 @@ export default class GitAdapter extends CachingAdapter {
await git.tag({ fs, dir: this.dir, ref: tag })
Logger.log('(git) push tag ' + tag)
await git.push({ fs, http, dir: this.dir, ref: tag, onAuth: () => this.onAuth() })
this.locked = tag
this.locked.push(tag)
}

async onAuth() {
return { username: this.server.username, password: this.server.password }
}

async freeLock() {
if (!this.locked) {
if (!this.locked.length) {
return
}

try {
const tags = await git.listTags({ fs, dir: this.dir })
const lockTags = tags.filter((tag) => tag.startsWith('floccus-lock-'))
for (const tag of lockTags) {
for (const tag of this.locked) {
Logger.log('(git) push: delete tag ' + tag)
await git.push({ fs, http, dir: this.dir, ref: tag, delete: true, onAuth: () => this.onAuth() })
}
Expand Down

0 comments on commit 527c25f

Please sign in to comment.