Skip to content

Commit

Permalink
Handle UNIQUEness of pinned status since v266 in importthread (pinned…
Browse files Browse the repository at this point in the history
… status from source is not imported)
  • Loading branch information
bepaald committed Mar 5, 2025
1 parent 19d044c commit a054a2f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion autoversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
#ifndef VERSION_H_
#define VERSION_H_

#define VERSIONDATE "20250305.155908"
#define VERSIONDATE "20250305.162305"

#endif
10 changes: 10 additions & 0 deletions signalbackup/importthread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,16 @@ table|sender_keys|sender_keys|71|CREATE TABLE sender_keys (_id INTEGER PRIMARY K
{
Logger::message(" No existing thread found in target database for this recipient, importing.");

// unpin thread from source database, to prevent uniqueness issues with target
if (source->d_database.tableContainsColumn("thread", source->d_thread_pinned) &&
d_database.tableContainsColumn("thread", d_thread_pinned))
{
// before dbv266, 'unpinned' meant the column was set to '0', after dbv266 it was 'NULL'. Make sure to use target's default here!
std::string target_pinned_default = d_database.getSingleResultAs<std::string>("SELECT dflt_value FROM pragma_table_info('thread') WHERE name = '" + d_thread_pinned + "'", std::string());
if (!source->d_database.exec("UPDATE thread SET " + source->d_thread_pinned + " = " + target_pinned_default))
Logger::warning("Failed to unpin threads in source database.");
}

// check identities and recipient prefs for presence of values, they may be there (even
// though no thread was found (for example via a group chat or deleted thread))
// get identities from target, drop all rows from source that are already present
Expand Down
5 changes: 3 additions & 2 deletions signalbackup/statics.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (C) 2022-2024 Selwin van Dijk
Copyright (C) 2022-2025 Selwin van Dijk
This file is part of signalbackup-tools.
Expand Down Expand Up @@ -494,7 +494,8 @@ std::map<std::string, std::vector<std::vector<std::string>>> const SignalBackup:
std::vector<std::vector<std::string>>{{"recipient_id", "thread_recipient_id", "recipient_ids"},
{"meaningful_messages", "message_count"},
{"has_delivery_receipt", "delivery_receipt_count"},
{"has_read_receipt", "read_receipt_count"}}),
{"has_read_receipt", "read_receipt_count"},
{"pinned_order", "pinned"}}),

std::make_pair("recipient",
std::vector<std::vector<std::string>>{{"aci", "uuid"},
Expand Down

0 comments on commit a054a2f

Please sign in to comment.