Skip to content

Commit 6a83b67

Browse files
committed
Fix stack overflow with TTS (readium#482)
1 parent 0cfb105 commit 6a83b67

File tree

3 files changed

+93
-11
lines changed

3 files changed

+93
-11
lines changed

Package.resolved

Lines changed: 79 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/Adapters/LCPSQLite/SQLiteLCPLicenseRepository.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import SQLite
1010

1111
public class LCPSQLiteLicenseRepository: LCPLicenseRepository {
1212
let licenses = Table("Licenses")
13-
let id = Expression<String>("id")
14-
let printsLeft = Expression<Int?>("printsLeft")
15-
let copiesLeft = Expression<Int?>("copiesLeft")
16-
let registered = Expression<Bool>("registered")
13+
let id = SQLite.Expression<String>("id")
14+
let printsLeft = SQLite.Expression<Int?>("printsLeft")
15+
let copiesLeft = SQLite.Expression<Int?>("copiesLeft")
16+
let registered = SQLite.Expression<Bool?>("registered")
17+
1718

1819
private let db: Connection
1920

@@ -98,15 +99,16 @@ public class LCPSQLiteLicenseRepository: LCPLicenseRepository {
9899
((try? db.scalar(licenses.filter(id == licenseID).count)) ?? 0) != 0
99100
}
100101

101-
private func get(_ column: Expression<Int?>, for licenseId: String) throws -> Int? {
102+
private func get(_ column: SQLite.Expression<Int?>, for licenseId: String) throws -> Int? {
102103
let query = licenses.select(column).filter(id == licenseId)
103104
for row in try db.prepare(query) {
104105
return try row.get(column)
105106
}
106107
return nil
107108
}
108109

109-
private func set(_ column: Expression<Int?>, to value: Int?, for licenseId: String) throws {
110+
111+
private func set(_ column: SQLite.Expression<Int?>, to value: Int?, for licenseId: String) throws {
110112
let filterLicense = licenses.filter(id == licenseId)
111113
try db.run(filterLicense.update(column <- value))
112114
}

Sources/Adapters/LCPSQLite/SQLiteLCPPassphraseRepository.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import ReadiumShared
1010
import SQLite
1111

1212
public class LCPSQLitePassphraseRepository: LCPPassphraseRepository, Loggable {
13-
let transactions = Table("Transactions")
14-
let licenseId = Expression<String>("licenseId")
15-
let provider = Expression<String>("origin")
16-
let userId = Expression<String?>("userId")
17-
let passphrase = Expression<String>("passphrase") // hashed.
13+
let transactions = SQLite.Table("Transactions")
14+
let licenseId = SQLite.Expression<String>("licenseId")
15+
let provider = SQLite.Expression<String>("origin")
16+
let userId = SQLite.Expression<String?>("userId")
17+
let passphrase = SQLite.Expression<String>("passphrase") // hashed
1818

1919
private let db: Connection
2020

@@ -66,6 +66,7 @@ public class LCPSQLitePassphraseRepository: LCPPassphraseRepository, Loggable {
6666
}
6767
}
6868

69+
6970
private func all() -> [String] {
7071
let query = transactions.select(passphrase)
7172
do {

0 commit comments

Comments
 (0)