Add "device_name" field to commit object.

This commit is contained in:
Jiaqiang Xu 2016-03-22 17:16:06 +08:00
parent b2aea39600
commit 809d3536ea
6 changed files with 15 additions and 0 deletions

View File

@ -620,6 +620,9 @@ commit_to_json_object (SeafCommit *commit)
commit->repo_desc);
json_object_set_string_or_null_member (object, "repo_category",
commit->repo_category);
if (commit->device_name)
json_object_set_string_member (object, "device_name", commit->device_name);
if (commit->encrypted)
json_object_set_string_member (object, "encrypted", "true");
@ -658,6 +661,7 @@ commit_from_json_object (const char *commit_id, json_t *object)
const char *repo_name;
const char *repo_desc;
const char *repo_category;
const char *device_name;
const char *encrypted = NULL;
int enc_version = 0;
const char *magic = NULL;
@ -686,6 +690,8 @@ commit_from_json_object (const char *commit_id, json_t *object)
if (!repo_desc)
repo_desc = "";
repo_category = json_object_get_string_or_null_member (object, "repo_category");
device_name = json_object_get_string_or_null_member (object, "device_name");
if (json_object_has_member (object, "encrypted"))
encrypted = json_object_get_string_or_null_member (object, "encrypted");
@ -755,6 +761,7 @@ commit_from_json_object (const char *commit_id, json_t *object)
commit->encrypted = FALSE;
if (repo_category)
commit->repo_category = g_strdup(repo_category);
commit->device_name = g_strdup(device_name);
if (commit->encrypted) {
commit->enc_version = enc_version;

View File

@ -28,6 +28,7 @@ struct _SeafCommit {
char *repo_name;
char *repo_desc;
char *repo_category;
char *device_name;
gboolean encrypted;
int enc_version;

View File

@ -1101,6 +1101,7 @@ convert_to_seafile_commit (SeafCommit *c)
"version", c->version,
"new_merge", c->new_merge,
"conflict", c->conflict,
"device_name", c->device_name,
NULL);
return commit;
}

View File

@ -3857,6 +3857,9 @@ commit_tree (SeafRepo *repo, const char *root_id,
commit->parent_id = g_strdup (repo->head->commit_id);
/* Add this computer's name to commit. */
commit->device_name = g_strdup(seaf->session->base.name);
if (unmerged) {
SeafRepoMergeInfo minfo;

View File

@ -63,6 +63,8 @@ public class Commit : Object {
public int64 rev_file_size { get; set; }
// Set if this commit renames a revision of a file
public string rev_renamed_old_path { get; set; }
public string device_name { get; set; }
}
} // namespace

View File

@ -4146,6 +4146,7 @@ convert_to_seafile_commit (SeafCommit *c)
"version", c->version,
"new_merge", c->new_merge,
"conflict", c->conflict,
"device_name", c->device_name,
NULL);
return commit;
}