Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(ext/node): (partial) impl sqlite 'backup' function#29842

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
edilson258 wants to merge1 commit intodenoland:main
base:main
Choose a base branch
Loading
fromedilson258:feat/sqlite-backup

Conversation

edilson258
Copy link
Contributor

Towards#29439

This PR aims to implement thenode:sqlite backup function

pub async fn op_backup_db(
state: Rc<RefCell<OpState>>,
) -> Result<i64, SqliteError> {
Ok(69)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nice

edilson258 reacted with laugh emoji
@edilson258
Copy link
ContributorAuthor

Hi@littledivy

I'm trying to impl. the node:sqlitebackup function.

Deno usesrusqlite lib under the hoods and it provides abackup function, so i decided to wrap it in anop and expose it to thejs land

function provided byrusqlite

fnbackup_db<P:AsRef<Path>>(src:&rusqlite::Connection,dst:P,progress:fn(rusqlite::backup::Progress),) ->Result<()>{ ...}

Node's backup function signature

asyncfunctionbackup(sourceDb:DatabaseSync,path:string,options?:BackupOptions,):Promise<void>;

At this point i know that therusqlite::Connection object needed by the rusqlite backup function is inside ofsourceDb but i dont know how to pass it to rustop

@edilson258edilson258 marked this pull request as ready for reviewJune 22, 2025 15:40
let src_conn_ref = source_db.conn.borrow();
let src_conn = src_conn_ref.as_ref().ok_or(SqliteError::SessionClosed)?;
let path = std::path::Path::new(&path);
let mut dst_conn = Connection::open(path)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think we'll need to add write permission checks here?

edilson258 reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

judging by the signature

functionbackup(sourceDb:DatabaseSync,path:string|Buffer|URL,options?:BackupOptions,):Promise<void>;

Sincepath can have different forms, we'll need to check diff permissions accordingly.

@edilson258
Copy link
ContributorAuthor

I can't figure how to pass the progress call back function fromjs land torust op. is there some code that i can inspire on??

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

@dsherretdsherretdsherret left review comments

@Tango992Tango992Tango992 left review comments

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@edilson258@dsherret@Tango992

[8]ページ先頭

©2009-2025 Movatter.jp