MCPcopy Create free account
hub / github.com/apache/httpd / pfs_move

Function pfs_move

modules/md/md_store_fs.c:951–1069  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

949/* moving */
950
951static apr_status_t pfs_move(void *baton, apr_pool_t *p, apr_pool_t *ptemp, va_list ap)
952{
953 md_store_fs_t *s_fs = baton;
954 const char *name, *from_group, *to_group, *from_dir, *to_dir, *arch_dir, *dir;
955 md_store_group_t from, to;
956 int archive;
957 apr_status_t rv;
958
959 (void)p;
960 from = (md_store_group_t)va_arg(ap, int);
961 to = (md_store_group_t)va_arg(ap, int);
962 name = va_arg(ap, const char*);
963 archive = va_arg(ap, int);
964
965 from_group = md_store_group_name(from);
966 to_group = md_store_group_name(to);
967 if (!strcmp(from_group, to_group)) {
968 return APR_EINVAL;
969 }
970
971 if ( !MD_OK(md_util_path_merge(&from_dir, ptemp, s_fs->base, from_group, name, NULL))
972 || !MD_OK(md_util_path_merge(&to_dir, ptemp, s_fs->base, to_group, name, NULL))) {
973 goto out;
974 }
975
976 if (!MD_OK(md_util_is_dir(from_dir, ptemp))) {
977 md_log_perror(MD_LOG_MARK, MD_LOG_DEBUG, rv, ptemp, "source is no dir: %s", from_dir);
978 goto out;
979 }
980
981 if (MD_OK(archive? md_util_is_dir(to_dir, ptemp) : APR_ENOENT)) {
982 int n = 1;
983 const char *narch_dir;
984
985 if ( !MD_OK(md_util_path_merge(&dir, ptemp, s_fs->base,
986 md_store_group_name(MD_SG_ARCHIVE), NULL))
987 || !MD_OK(apr_dir_make_recursive(dir, MD_FPROT_D_UONLY, ptemp))
988 || !MD_OK(md_util_path_merge(&arch_dir, ptemp, dir, name, NULL))) {
989 goto out;
990 }
991
992#ifdef WIN32
993 /* WIN32 and handling of files/dirs. What can one say? */
994
995 while (n < 1000) {
996 narch_dir = apr_psprintf(ptemp, "%s.%d", arch_dir, n);
997 rv = md_util_is_dir(narch_dir, ptemp);
998 if (APR_STATUS_IS_ENOENT(rv)) {
999 md_log_perror(MD_LOG_MARK, MD_LOG_TRACE1, rv, ptemp, "using archive dir: %s",
1000 narch_dir);
1001 break;
1002 }
1003 else {
1004 ++n;
1005 narch_dir = NULL;
1006 }
1007 }
1008

Callers

nothing calls this directly

Calls 5

md_store_group_nameFunction · 0.85
md_util_path_mergeFunction · 0.85
md_util_is_dirFunction · 0.85
md_log_perrorFunction · 0.85
dispatchFunction · 0.70

Tested by

no test coverage detected