Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Commit

Permalink
fix(worker): appstream file paths should use underscore sanitization
Browse files Browse the repository at this point in the history
BREAKING CHANGE: appstream file paths should use underscores to match the appstream ID

issue #566
  • Loading branch information
btkostner committed Jul 11, 2018
1 parent c648552 commit 43709fb
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/worker/task/appstream/content-rating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AppstreamContentRating extends Task {
* @return {string}
*/
public get name () {
return sanitize(this.worker.context.nameDomain, '-')
return sanitize(this.worker.context.nameDomain, '_')
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/worker/task/appstream/description.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AppstreamDescription extends Task {
* @return {string}
*/
public get name () {
return sanitize(this.worker.context.nameDomain, '-')
return sanitize(this.worker.context.nameDomain, '_')
}

/**
Expand Down
19 changes: 5 additions & 14 deletions src/worker/task/appstream/id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,13 @@ import { Task } from '../task'

export class AppstreamId extends Task {

/**
* Returns what the appstream ID should be
*
* @return {string}
*/
public get id () {
return sanitize(this.worker.context.nameDomain, '_')
}

/**
* Returns the main appstream file name
*
* @return {string}
*/
public get name () {
return sanitize(this.worker.context.nameDomain, '-')
return sanitize(this.worker.context.nameDomain, '_')
}

/**
Expand All @@ -53,15 +44,15 @@ export class AppstreamId extends Task {
const id = $('component > id')

if (id.length === 0) {
$('component').prepend(`<id>${this.id}</id>`)
$('component').prepend(`<id>${this.name}</id>`)
await fs.writeFile(this.path, $.xml())

throw new Log(Log.Level.WARN, 'Missing "id" field')
} else if (id.text() !== this.id) {
id.text(this.id)
} else if (id.text() !== this.name) {
id.text(this.name)
await fs.writeFile(this.path, $.xml())

throw new Log(Log.Level.WARN, `"id" field should be "${this.id}"`)
throw new Log(Log.Level.WARN, `"id" field should be "${this.name}"`)
}
}
}
2 changes: 1 addition & 1 deletion src/worker/task/appstream/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export class Appstream extends WrapperTask {
* @return {string}
*/
public get name () {
return sanitize(this.worker.context.nameDomain, '-')
return sanitize(this.worker.context.nameDomain, '_')
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/worker/task/appstream/license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AppstreamLicense extends Task {
* @return {string}
*/
public get name () {
return sanitize(this.worker.context.nameDomain, '-')
return sanitize(this.worker.context.nameDomain, '_')
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/worker/task/appstream/name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AppstreamName extends Task {
* @return {string}
*/
public get name () {
return sanitize(this.worker.context.nameDomain, '-')
return sanitize(this.worker.context.nameDomain, '_')
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/worker/task/appstream/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class AppstreamRelease extends Task {
* @return {string}
*/
public get name () {
return sanitize(this.worker.context.nameDomain, '-')
return sanitize(this.worker.context.nameDomain, '_')
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/worker/task/appstream/screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AppstreamScreenshot extends Task {
* @return {string}
*/
public get name () {
return sanitize(this.worker.context.nameDomain, '-')
return sanitize(this.worker.context.nameDomain, '_')
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/worker/task/appstream/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AppstreamStripe extends Task {
* @return {string}
*/
public get name () {
return sanitize(this.worker.context.nameDomain, '-')
return sanitize(this.worker.context.nameDomain, '_')
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/worker/task/appstream/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AppstreamSummary extends Task {
* @return {string}
*/
public get name () {
return sanitize(this.worker.context.nameDomain, '-')
return sanitize(this.worker.context.nameDomain, '_')
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/worker/task/appstream/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class AppstreamValidate extends Task {
* @return {string}
*/
public get name () {
return sanitize(this.worker.context.nameDomain, '-')
return sanitize(this.worker.context.nameDomain, '_')
}

/**
Expand Down
4 changes: 2 additions & 2 deletions test/spec/worker/task/appstream/content-rating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('missing content_rating causes an error', async (t) => {
nameDomain: 'com.github.philip-scott.spice-up'
})

await worker.mock('task/appstream/blank.xml', 'package/usr/share/metainfo/com.github.philip-scott.spice-up.appdata.xml')
await worker.mock('task/appstream/blank.xml', 'package/usr/share/metainfo/com.github.philip_scott.spice_up.appdata.xml')

worker.tasks.push(AppstreamContentRating)

Expand All @@ -33,7 +33,7 @@ test('missing a content_rating attribute causes an error', async (t) => {
nameDomain: 'com.github.philip-scott.spice-up'
})

await worker.mock('task/appstream/content-rating.xml', 'package/usr/share/metainfo/com.github.philip-scott.spice-up.appdata.xml')
await worker.mock('task/appstream/content-rating.xml', 'package/usr/share/metainfo/com.github.philip_scott.spice_up.appdata.xml')

worker.tasks.push(AppstreamContentRating)

Expand Down
2 changes: 1 addition & 1 deletion test/spec/worker/task/appstream/id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('passes with a matching ID', async (t) => {
nameDomain: 'com.github.philip-scott.spice-up'
})

await worker.mock('task/appstream/spice-up.xml', 'package/usr/share/metainfo/com.github.philip-scott.spice-up.appdata.xml')
await worker.mock('task/appstream/spice-up.xml', 'package/usr/share/metainfo/com.github.philip_scott.spice_up.appdata.xml')

worker.tasks.push(AppstreamId)

Expand Down
4 changes: 2 additions & 2 deletions test/spec/worker/task/appstream/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test('com.github.philip-scott.spice-up passes appstream tests', async (t) => {
nameDomain: 'com.github.philip-scott.spice-up'
})

await worker.mock('task/appstream/spice-up.xml', 'package/usr/share/metainfo/com.github.philip-scott.spice-up.appdata.xml')
await worker.mock('task/appstream/spice-up.xml', 'package/usr/share/metainfo/com.github.philip_scott.spice_up.appdata.xml')

worker.tasks.push(Appstream)

Expand All @@ -42,7 +42,7 @@ test('basic errors get concated to single log', async (t) => {
nameDomain: 'com.github.philip-scott.spice-up'
})

await worker.mock('task/appstream/blank.xml', 'package/usr/share/metainfo/com.github.philip-scott.spice-up.appdata.xml')
await worker.mock('task/appstream/blank.xml', 'package/usr/share/metainfo/com.github.philip_scott.spice_up.appdata.xml')

worker.tasks.push(Appstream)

Expand Down
2 changes: 1 addition & 1 deletion test/spec/worker/task/appstream/screenshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('passes with screenshots specified', async (t) => {
nameDomain: 'com.github.philip-scott.spice-up'
})

await worker.mock('task/appstream/spice-up.xml', 'package/usr/share/metainfo/com.github.philip-scott.spice-up.appdata.xml')
await worker.mock('task/appstream/spice-up.xml', 'package/usr/share/metainfo/com.github.philip_scott.spice_up.appdata.xml')

worker.tasks.push(AppstreamScreenshot)

Expand Down
4 changes: 2 additions & 2 deletions test/spec/worker/task/appstream/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test('passes with a valid appstream file', async (t) => {
nameDomain: 'com.github.philip-scott.spice-up'
})

await worker.mock('task/appstream/spice-up.xml', 'package/usr/share/metainfo/com.github.philip-scott.spice-up.appdata.xml')
await worker.mock('task/appstream/spice-up.xml', 'package/usr/share/metainfo/com.github.philip_scott.spice_up.appdata.xml')

worker.tasks.push(AppstreamValidate)

Expand All @@ -33,7 +33,7 @@ test('fails with a blank appstream file', async (t) => {
nameDomain: 'com.github.philip-scott.spice-up'
})

await worker.mock('task/appstream/blank.xml', 'package/usr/share/metainfo/com.github.philip-scott.spice-up.appdata.xml')
await worker.mock('task/appstream/blank.xml', 'package/usr/share/metainfo/com.github.philip_scott.spice_up.appdata.xml')

worker.tasks.push(AppstreamValidate)

Expand Down

0 comments on commit 43709fb

Please sign in to comment.