mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-25 22:48:36 +00:00
Fix subdir cannot be unshared issue.
This commit is contained in:
@@ -2463,28 +2463,17 @@ seafile_unshare_subdir_for_user (const char *repo_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *real_path;
|
char *real_path;
|
||||||
char *vrepo_id;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
real_path = format_dir_path (path);
|
real_path = format_dir_path (path);
|
||||||
|
|
||||||
vrepo_id = seaf_repo_manager_get_virtual_repo_id (seaf->repo_mgr, repo_id,
|
ret = seaf_share_manager_unshare_subdir (seaf->share_mgr,
|
||||||
real_path, owner);
|
repo_id, real_path, owner, share_user);
|
||||||
if (!vrepo_id) {
|
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
|
||||||
"Failed to get shared sub repo");
|
|
||||||
ret = -1;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = seaf_share_manager_remove_share (seaf->share_mgr, vrepo_id, owner, share_user);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
||||||
"Failed to unshare subdir for user");
|
"Failed to unshare subdir for user");
|
||||||
}
|
}
|
||||||
g_free (vrepo_id);
|
|
||||||
|
|
||||||
out:
|
|
||||||
g_free (real_path);
|
g_free (real_path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -2752,29 +2741,17 @@ seafile_unshare_subdir_for_group (const char *repo_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *real_path;
|
char *real_path;
|
||||||
char *vrepo_id;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
real_path = format_dir_path (path);
|
real_path = format_dir_path (path);
|
||||||
|
|
||||||
vrepo_id = seaf_repo_manager_get_virtual_repo_id (seaf->repo_mgr, repo_id,
|
ret = seaf_share_manager_unshare_group_subdir (seaf->share_mgr, repo_id,
|
||||||
real_path, owner);
|
real_path, owner, share_group);
|
||||||
if (!vrepo_id) {
|
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
|
||||||
"Failed to get shared sub repo");
|
|
||||||
ret = -1;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = seaf_repo_manager_del_group_repo (seaf->repo_mgr, vrepo_id,
|
|
||||||
share_group, error);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
||||||
"Failed to unshare subdir for group");
|
"Failed to unshare subdir for group");
|
||||||
}
|
}
|
||||||
g_free (vrepo_id);
|
|
||||||
|
|
||||||
out:
|
|
||||||
g_free (real_path);
|
g_free (real_path);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -500,6 +500,28 @@ seaf_share_manager_remove_share (SeafShareManager *mgr, const char *repo_id,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
seaf_share_manager_unshare_subdir (SeafShareManager* mgr,
|
||||||
|
const char *orig_repo_id,
|
||||||
|
const char *path,
|
||||||
|
const char *from_email,
|
||||||
|
const char *to_email)
|
||||||
|
{
|
||||||
|
if (seaf_db_statement_query (mgr->seaf->db,
|
||||||
|
"DELETE FROM SharedRepo WHERE "
|
||||||
|
"from_email = ? AND to_email = ? "
|
||||||
|
"AND repo_id IN "
|
||||||
|
"(SELECT repo_id FROM VirtualRepo WHERE "
|
||||||
|
"origin_repo = ? AND path = ?)",
|
||||||
|
4, "string", from_email,
|
||||||
|
"string", to_email,
|
||||||
|
"string", orig_repo_id,
|
||||||
|
"string", path) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
seaf_share_manager_remove_repo (SeafShareManager *mgr, const char *repo_id)
|
seaf_share_manager_remove_repo (SeafShareManager *mgr, const char *repo_id)
|
||||||
{
|
{
|
||||||
@@ -681,3 +703,25 @@ seaf_get_shared_repo_by_path (SeafRepoManager *mgr,
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
seaf_share_manager_unshare_group_subdir (SeafShareManager* mgr,
|
||||||
|
const char *repo_id,
|
||||||
|
const char *path,
|
||||||
|
const char *owner,
|
||||||
|
int group_id)
|
||||||
|
{
|
||||||
|
if (seaf_db_statement_query (mgr->seaf->db,
|
||||||
|
"DELETE FROM RepoGroup WHERE "
|
||||||
|
"user_name = ? AND group_id = ? "
|
||||||
|
"AND repo_id IN "
|
||||||
|
"(SELECT repo_id FROM VirtualRepo WHERE "
|
||||||
|
"origin_repo = ? AND path = ?)",
|
||||||
|
4, "string", owner,
|
||||||
|
"int", group_id,
|
||||||
|
"string", repo_id,
|
||||||
|
"string", path) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -57,6 +57,14 @@ int
|
|||||||
seaf_share_manager_remove_share (SeafShareManager *mgr, const char *repo_id,
|
seaf_share_manager_remove_share (SeafShareManager *mgr, const char *repo_id,
|
||||||
const char *from_email, const char *to_email);
|
const char *from_email, const char *to_email);
|
||||||
|
|
||||||
|
int
|
||||||
|
seaf_share_manager_unshare_subdir (SeafShareManager* mgr,
|
||||||
|
const char *orig_repo_id,
|
||||||
|
const char *path,
|
||||||
|
const char *from_email,
|
||||||
|
const char *to_email);
|
||||||
|
|
||||||
|
|
||||||
/* Remove all share info of a repo. */
|
/* Remove all share info of a repo. */
|
||||||
int
|
int
|
||||||
seaf_share_manager_remove_repo (SeafShareManager *mgr, const char *repo_id);
|
seaf_share_manager_remove_repo (SeafShareManager *mgr, const char *repo_id);
|
||||||
@@ -82,6 +90,12 @@ seaf_get_shared_repo_by_path (SeafRepoManager *mgr,
|
|||||||
const char *shared_to,
|
const char *shared_to,
|
||||||
int is_org,
|
int is_org,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
int
|
||||||
|
seaf_share_manager_unshare_group_subdir (SeafShareManager* mgr,
|
||||||
|
const char *repo_id,
|
||||||
|
const char *path,
|
||||||
|
const char *owner,
|
||||||
|
int group_id);
|
||||||
|
|
||||||
#endif /* SHARE_MGR_H */
|
#endif /* SHARE_MGR_H */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user