mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-12 21:35:30 +00:00
Check if obj already exists when write obj.
This commit is contained in:
@@ -879,6 +879,11 @@ save_commit (SeafCommitManager *manager,
|
|||||||
char *data;
|
char *data;
|
||||||
gsize len;
|
gsize len;
|
||||||
|
|
||||||
|
if (seaf_obj_store_obj_exists (manager->obj_store,
|
||||||
|
repo_id, version,
|
||||||
|
commit->commit_id))
|
||||||
|
return 0;
|
||||||
|
|
||||||
object = commit_to_json_object (commit);
|
object = commit_to_json_object (commit);
|
||||||
|
|
||||||
data = json_dumps (object, 0);
|
data = json_dumps (object, 0);
|
||||||
|
@@ -462,6 +462,12 @@ write_seafile (SeafFSManager *fs_mgr,
|
|||||||
guint8 *compressed;
|
guint8 *compressed;
|
||||||
int outlen;
|
int outlen;
|
||||||
|
|
||||||
|
if (seaf_obj_store_obj_exists (fs_mgr->obj_store, repo_id, version, seafile_id)) {
|
||||||
|
ret = 0;
|
||||||
|
free (ondisk);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (seaf_compress (ondisk, ondisk_size, &compressed, &outlen) < 0) {
|
if (seaf_compress (ondisk, ondisk_size, &compressed, &outlen) < 0) {
|
||||||
seaf_warning ("Failed to compress seafile obj %s:%s.\n",
|
seaf_warning ("Failed to compress seafile obj %s:%s.\n",
|
||||||
repo_id, seafile_id);
|
repo_id, seafile_id);
|
||||||
@@ -477,6 +483,11 @@ write_seafile (SeafFSManager *fs_mgr,
|
|||||||
free (ondisk);
|
free (ondisk);
|
||||||
} else {
|
} else {
|
||||||
ondisk = create_seafile_v0 (cdc, &ondisk_size, seafile_id);
|
ondisk = create_seafile_v0 (cdc, &ondisk_size, seafile_id);
|
||||||
|
if (seaf_obj_store_obj_exists (fs_mgr->obj_store, repo_id, version, seafile_id)) {
|
||||||
|
ret = 0;
|
||||||
|
g_free (ondisk);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
if (seaf_obj_store_write_obj (fs_mgr->obj_store, repo_id, version, seafile_id,
|
if (seaf_obj_store_write_obj (fs_mgr->obj_store, repo_id, version, seafile_id,
|
||||||
ondisk, ondisk_size, FALSE) < 0)
|
ondisk, ondisk_size, FALSE) < 0)
|
||||||
@@ -1389,6 +1400,9 @@ seafile_save (SeafFSManager *fs_mgr,
|
|||||||
int len;
|
int len;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
if (seaf_obj_store_obj_exists (fs_mgr->obj_store, repo_id, version, file->file_id))
|
||||||
|
return 0;
|
||||||
|
|
||||||
data = seafile_to_data (file, &len);
|
data = seafile_to_data (file, &len);
|
||||||
if (!data)
|
if (!data)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1860,6 +1874,9 @@ seaf_dir_save (SeafFSManager *fs_mgr,
|
|||||||
if (memcmp (dir->dir_id, EMPTY_SHA1, 40) == 0)
|
if (memcmp (dir->dir_id, EMPTY_SHA1, 40) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (seaf_obj_store_obj_exists (fs_mgr->obj_store, repo_id, version, dir->dir_id))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (seaf_obj_store_write_obj (fs_mgr->obj_store, repo_id, version, dir->dir_id,
|
if (seaf_obj_store_write_obj (fs_mgr->obj_store, repo_id, version, dir->dir_id,
|
||||||
dir->ondisk, dir->ondisk_size, FALSE) < 0)
|
dir->ondisk, dir->ondisk_size, FALSE) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
Reference in New Issue
Block a user