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

Add enc_version and salt to RepoInfo. #282

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ly1217
Copy link
Contributor

@ly1217 ly1217 commented Oct 31, 2019

No description provided.

@ly1217 ly1217 force-pushed the record_enc_version_and_salt branch 6 times, most recently from 09fdb0e to 9a2afb2 Compare October 31, 2019 10:38
@ly1217 ly1217 force-pushed the record_enc_version_and_salt branch from 9a2afb2 to fd6fe4d Compare October 31, 2019 10:44
@@ -178,6 +178,8 @@ CREATE TABLE IF NOT EXISTS RepoInfo (id BIGINT NOT NULL PRIMARY KEY AUTO_INCREME
is_encrypted INTEGER,
last_modifier VARCHAR(255),
status INTEGER DEFAULT 0,
enc_version INTEGER,
salt CHAR(64),
Copy link
Member

Choose a reason for hiding this comment

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

这两个新加的列需要设置默认值,enc_version 默认为 0,salt 默认为 NULL。这样代码才能知道需要补充这些信息。

@@ -1060,7 +1071,8 @@ create_tables_mysql (SeafRepoManager *mgr)
sql = "CREATE TABLE IF NOT EXISTS RepoInfo (id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT, "
"repo_id CHAR(36), "
"name VARCHAR(255) NOT NULL, update_time BIGINT, version INTEGER, "
"is_encrypted INTEGER, last_modifier VARCHAR(255), status INTEGER DEFAULT 0, UNIQUE INDEX(repo_id)) ENGINE=INNODB";
"is_encrypted INTEGER, last_modifier VARCHAR(255), status INTEGER DEFAULT 0, "
"enc_version INTEGER, salt CHAR(64), UNIQUE INDEX(repo_id)) ENGINE=INNODB";
Copy link
Member

Choose a reason for hiding this comment

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

这里也要加默认值。

@@ -2323,7 +2344,8 @@ seaf_repo_manager_get_repos_by_owner (SeafRepoManager *mgr,
if (!repo->is_corrupted)
Copy link
Member

Choose a reason for hiding this comment

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

上面这段代码中的判断 (!repo->name || !repo->last_modifier) 不容易看懂是什么意思。其实这样写是由于我们历史上在 RepoInfo 这个表增加过两次字段,第一次加入了 repo_name 等字段,第二次加入了 last_modifier。所以由于数据库升级,所以要处理数据库中的默认值。

这里最好把这个写一个小的函数,里面检查一下 repo 对象的所有字段,只要发现一个是未赋值的,就需要加载 commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants