Skip to content

[request] Have drag-and-drop test for invalid DB, switch to import #1883

@alexchandel

Description

@alexchandel

Describe the new feature

Every valid unencrypted SQLite file begins with the byte string 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00. When a file is drag-and-dropped onto a window, the DB4S should test whether the file appears to be a SQLite database. If so, proceed down the "Open Database" handler. But if not, DB4S should treat it as a CSV file and pass it to the "Import Table from CSV File..." handler.

Avoiding misinterpreting encrypted files

At present, DB4S assumes the CSV file is encrypted and opens a decryption prompt. A simple way to avoid mistreating an encrypted database is to test whether the first 1024 bytes of the file are UTF-8, for which blindingly fast algorithms exist, completing in < 1µs. The odds of the first 1k of RC4 or AES being valid UTF-8 are negligible. If it's UTF-8, import it as a table; if not, assume it's encrypted (or just ask the user).

Additional info

Does this feature exist in another product or project? Please provide a link.

File detection for drag-and-drop is quite common.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions