Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support moving Signal Config directory from Linux to Windows #3917

Closed
1 task done
ivan opened this issue Jan 24, 2020 · 7 comments
Closed
1 task done

Support moving Signal Config directory from Linux to Windows #3917

ivan opened this issue Jan 24, 2020 · 7 comments

Comments

@ivan
Copy link

ivan commented Jan 24, 2020

  • I have searched open and closed issues for duplicates

Bug Description

After moving ~/.config/Signal from a Linux machine to %APPDATA%\Signal on a Windows machine, Signal-Desktop seems to garbage-collect all of my old attachments and sticker packs. My ~4GB of attachments in attachments.noindex are deleted, as well as most of stickers.noindex.

Attachments and stickers are not always deleted, for me this happened twice: on first run (after which I copied them back), and after the update to v1.30.0.

The moved profile does not appear to have any issues other than the loss of attachments and stickers.

Steps to Reproduce

I am not sure, but I think that moving a Signal-Desktop profile from Linux to Windows, then updating Signal-Desktop or whatever triggers attachment GC, should manifest this problem.

Actual Result: Most files are deleted from attachments.noindex and stickers.noindex

Expected Result: Attachments and stickers remain in attachments.noindex and stickers.noindex

Screenshots

Annotation 2020-01-24 025124

Platform Info

Signal Version: v1.30.0

Operating System: Windows 10 1909

Linked Device Version: Signal-iOS 3.2.0.10

Link to Debug Log

https://debuglogs.org/c09f0f366193edeee998b4863f5e8e8d094855380941168cbbc8fdc3a84531b9

@scottnonnenberg-signal scottnonnenberg-signal changed the title Attachments and stickers are deleted after moving profile to Windows Support moving Signal Config directory from Linux to Windows Jan 24, 2020
@stale
Copy link

stale bot commented Sep 27, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@ivan
Copy link
Author

ivan commented Nov 9, 2021

This is still an issue, unfortunately. With the latest version of Signal-Desktop (5.23.0) on Windows 10 21H1, on startup Signal-Desktop will sometimes GC the attachments and delete the ones that were created in my old Linux profile. The attachments still work if they are copied in after GC, though. My experience of using Signal-Desktop involves, after every update, copying the attachments out of an archive back into the Signal-Desktop profile directory.

@scottnonnenberg-signal
Copy link
Contributor

We check for 'orphaned' files, files that are no longer pointed at by a message or conversation, whenever we start up with a new version number. That's why it seems to only work sometimes.

Now, why are these files considered orphaned on Windows? It's because the path values inside of your attachments look like this on Linux: '91/91ad4234233...' and on Windows they look like this: '91\91ad4234233...'.

I think we'd welcome a PR that would fix this orphaned file checking. Start with cleanupOrphanedAttachments in app/main.ts.

@outpoints outpoints mentioned this issue Mar 1, 2023
2 tasks
@pippi1otta
Copy link

the path values inside of your attachments look like this on Linux: '91/91ad4234233...' and on Windows they look like this: '91\91ad4234233...'.

Does the directory name (91/) have to be stored (hard-coded) in the database? Could it be prepended in code instead? Computing it is trivial - taking the first two (or whatever) characters from the file name is a very cheap operation.

This would make the path values in the database resilient to any future directory structure-related changes/issues - the directory separator issue here, also a potential change in the directory structure (flattening, deepening). Only a handful of places in the code would need to change, and migrating of the database records would not be needed.

@EmmanuelIT
Copy link

I am having exactly the same problem but I am moving the Signal Desktop folder structure from Windows to Linux (aka from '' to '/'). As I can understand, nothing has been done to solve this issue the last 4 years.

I tried to write a python script to convert the back-slashes \ into slashes / on the json column in the messages table in db.sqlite Signal database that holds the messages.

Unfortunately I did not manage to update the "json" column because I am getting the error message:
sqlcipher3.dbapi2.OperationalError: no such tokenizer: signal_tokenizer

My script is as follows:

from sqlcipher3 import dbapi2 as sqlite

# Key from ~/.config/Signal/config.json
key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"


conn = sqlite.connect("db.sqlite")

cur = conn.cursor()
cur.execute(f"PRAGMA key=\"x'{key}'\";");
cur.execute("SELECT rowid, json FROM messages WHERE hasAttachments = 1;")

for row in cur.fetchall():
    rowid = row[0]
    json = row[1]
    json = json.replace('\\', '/')

    upd = conn.cursor()

    # The following command will fail with an error message
    upd.execute(f'''UPDATE messages SET json = '{json}' WHERE rowid = {rowid}''')

    upd.close()

cur.close()
conn.commit()

conn.close()

Does anybody know what this signal_tokenizer is, and how use it in my script to solve the problem ?

@norstbox
Copy link
Contributor

@EmmanuelIT
Copy link

@norstbox

Thank you very much.
The article helped me solve the problem.

I just had to remove the triggers on messages table, run the query and then recreate the triggers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

7 participants