-
Notifications
You must be signed in to change notification settings - Fork 225
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
base: master
Are you sure you want to change the base?
Conversation
09fdb0e
to
9a2afb2
Compare
9a2afb2
to
fd6fe4d
Compare
@@ -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), |
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
No description provided.