Skip to content

Commit 996e6dd

Browse files
committed
fix unsetting pin/bleeding edge mode when also installing or updating
1 parent 65f1873 commit 996e6dd

File tree

5 files changed

+42
-34
lines changed

5 files changed

+42
-34
lines changed

src/browser.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ bool Browser::apply()
868868
const Version *target = *entry->target;
869869

870870
if(target)
871-
tx->install(target, entry->flags.value_or(0));
871+
tx->install(target, entry->flags.value_or(entry->regEntry.flags));
872872
else
873873
tx->uninstall(entry->regEntry);
874874

src/install.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bool InstallTask::start()
4040
// prevent file conflicts (don't worry, the registry push is reverted)
4141
try {
4242
std::vector<Path> conflicts;
43-
tx()->registry()->push(m_version, &conflicts);
43+
tx()->registry()->push(m_version, m_flags, &conflicts);
4444

4545
if(!conflicts.empty()) {
4646
for(const Path &path : conflicts) {
@@ -121,11 +121,7 @@ void InstallTask::commit()
121121

122122
tx()->receipt()->addInstall(m_version, m_oldEntry);
123123

124-
const Registry::Entry newEntry = tx()->registry()->push(m_version);
125-
126-
if(m_flags)
127-
tx()->registry()->setFlags(newEntry, m_flags);
128-
124+
const Registry::Entry &newEntry = tx()->registry()->push(m_version, m_flags);
129125
tx()->registerAll(true, newEntry);
130126
}
131127

src/registry.cpp

+30-22
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ Registry::Registry(const Path &path)
3434

3535
// entry queries
3636
m_insertEntry = m_db.prepare(
37-
"INSERT INTO entries(remote, category, package, desc, type, version, author)"
38-
"VALUES(?, ?, ?, ?, ?, ?, ?);"
37+
"INSERT INTO entries(remote, category, package, desc, type, version, author, flags)"
38+
"VALUES(?, ?, ?, ?, ?, ?, ?, ?);"
3939
);
4040

4141
m_updateEntry = m_db.prepare(
4242
"UPDATE entries "
43-
"SET desc = ?, type = ?, version = ?, author = ? WHERE id = ?"
43+
"SET desc = ?, type = ?, version = ?, author = ?, flags = ? WHERE id = ?"
4444
);
4545

4646
m_setFlags = m_db.prepare("UPDATE entries SET flags = ? WHERE id = ?");
@@ -146,7 +146,8 @@ void Registry::migrate()
146146
}
147147
}
148148

149-
auto Registry::push(const Version *ver, std::vector<Path> *conflicts) -> Entry
149+
auto Registry::push(const Version *ver, const int flags,
150+
std::vector<Path> *conflicts) -> Entry
150151
{
151152
m_db.savepoint();
152153

@@ -165,21 +166,25 @@ auto Registry::push(const Version *ver, std::vector<Path> *conflicts) -> Entry
165166

166167
// register or update package and version
167168
if(entryId) {
168-
m_updateEntry->bind(1, pkg->description());
169-
m_updateEntry->bind(2, pkg->type());
170-
m_updateEntry->bind(3, ver->name().toString());
171-
m_updateEntry->bind(4, ver->author());
172-
m_updateEntry->bind(5, entryId);
169+
int col = 1;
170+
m_updateEntry->bind(col++, pkg->description());
171+
m_updateEntry->bind(col++, pkg->type());
172+
m_updateEntry->bind(col++, ver->name().toString());
173+
m_updateEntry->bind(col++, ver->author());
174+
m_updateEntry->bind(col++, flags);
175+
m_updateEntry->bind(col++, entryId);
173176
m_updateEntry->exec();
174177
}
175178
else {
176-
m_insertEntry->bind(1, ri->name());
177-
m_insertEntry->bind(2, cat->name());
178-
m_insertEntry->bind(3, pkg->name());
179-
m_insertEntry->bind(4, pkg->description());
180-
m_insertEntry->bind(5, pkg->type());
181-
m_insertEntry->bind(6, ver->name().toString());
182-
m_insertEntry->bind(7, ver->author());
179+
int col = 1;
180+
m_insertEntry->bind(col++, ri->name());
181+
m_insertEntry->bind(col++, cat->name());
182+
m_insertEntry->bind(col++, pkg->name());
183+
m_insertEntry->bind(col++, pkg->description());
184+
m_insertEntry->bind(col++, pkg->type());
185+
m_insertEntry->bind(col++, ver->name().toString());
186+
m_insertEntry->bind(col++, ver->author());
187+
m_insertEntry->bind(col++, flags);
183188
m_insertEntry->exec();
184189

185190
entryId = m_db.lastInsertId();
@@ -189,10 +194,11 @@ auto Registry::push(const Version *ver, std::vector<Path> *conflicts) -> Entry
189194
for(const Source *src : ver->sources()) {
190195
const Path &path = src->targetPath();
191196

192-
m_insertFile->bind(1, entryId);
193-
m_insertFile->bind(2, path.join(false));
194-
m_insertFile->bind(3, src->sections());
195-
m_insertFile->bind(4, src->typeOverride());
197+
int col = 1;
198+
m_insertFile->bind(col++, entryId);
199+
m_insertFile->bind(col++, path.join(false));
200+
m_insertFile->bind(col++, src->sections());
201+
m_insertFile->bind(col++, src->typeOverride());
196202

197203
try {
198204
m_insertFile->exec();
@@ -215,8 +221,10 @@ auto Registry::push(const Version *ver, std::vector<Path> *conflicts) -> Entry
215221
}
216222
else {
217223
m_db.release();
218-
return {entryId, ri->name(), cat->name(),
219-
pkg->name(), pkg->description(), pkg->type(), ver->name(), ver->author()};
224+
return {
225+
entryId, ri->name(), cat->name(), pkg->name(), pkg->description(),
226+
pkg->type(), ver->name(), ver->author(), flags
227+
};
220228
}
221229
}
222230

src/registry.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Registry {
6666
std::vector<Entry> getEntries(const std::string &) const;
6767
std::vector<File> getFiles(const Entry &) const;
6868
std::vector<File> getMainFiles(const Entry &) const;
69-
Entry push(const Version *, std::vector<Path> *conflicts = nullptr);
69+
Entry push(const Version *, int flags = 0, std::vector<Path> *conflicts = nullptr);
7070
void setFlags(const Entry &, int flags);
7171
void forget(const Entry &);
7272

test/registry.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TEST_CASE("query installed package", M) {
3535

3636
Registry reg;
3737

38-
const Registry::Entry &entry = reg.push(&ver);
38+
const Registry::Entry &entry = reg.push(&ver, 2);
3939
REQUIRE(entry);
4040
REQUIRE(entry.id == 1);
4141
REQUIRE(entry.remote == "Remote Name");
@@ -44,6 +44,7 @@ TEST_CASE("query installed package", M) {
4444
REQUIRE(entry.type == Package::ScriptType);
4545
REQUIRE(entry.version.toString() == "1.0");
4646
REQUIRE(entry.author == "John Doe");
47+
REQUIRE(entry.flags == 2);
4748

4849
const Registry::Entry &selectEntry = reg.getEntry(&pkg);
4950
REQUIRE(selectEntry.id == entry.id);
@@ -54,6 +55,7 @@ TEST_CASE("query installed package", M) {
5455
REQUIRE(selectEntry.type == entry.type);
5556
REQUIRE(selectEntry.version == entry.version);
5657
REQUIRE(selectEntry.author == entry.author);
58+
REQUIRE(selectEntry.flags == entry.flags);
5759
}
5860

5961
TEST_CASE("bump version", M) {
@@ -63,16 +65,18 @@ TEST_CASE("bump version", M) {
6365
ver2.addSource(new Source("file", "url", &ver2));
6466

6567
Registry reg;
66-
reg.push(&ver);
68+
reg.push(&ver, 1);
6769

6870
const Registry::Entry &entry1 = reg.getEntry(&pkg);
6971
REQUIRE(entry1.version.toString() == "1.0");
7072
CHECK(entry1.author == "John Doe");
73+
CHECK(entry1.flags == 1);
7174

72-
reg.push(&ver2);
75+
reg.push(&ver2, 2);
7376
const Registry::Entry &entry2 = reg.getEntry(&pkg);
7477
REQUIRE(entry2.version.toString() == "2.0");
7578
CHECK(entry2.author == "");
79+
REQUIRE(entry2.flags == 2);
7680

7781
REQUIRE(entry2.id == entry1.id);
7882
}
@@ -151,7 +155,7 @@ TEST_CASE("file conflicts", M) {
151155
CHECK(reg.getEntry(&pkg).id == 0); // still uninstalled
152156

153157
std::vector<Path> conflicts;
154-
const auto &pushResult = reg.push(&ver, &conflicts);
158+
const auto &pushResult = reg.push(&ver, 0, &conflicts);
155159
CHECK(pushResult.id == 0);
156160

157161
REQUIRE(conflicts.size() == 1);

0 commit comments

Comments
 (0)