httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@locus.apache.org
Subject cvs commit: apache-2.0/src/modules/dav/fs repos.c
Date Mon, 03 Jul 2000 12:08:37 GMT
gstein      00/07/03 05:08:36

  Modified:    src/modules/dav/fs repos.c
  Log:
  re-enable the "move by rename" optimization (now that we have the
      ap_finfo_t.device field)
  re-enable the "executable" live property (now that we have a chmod()
      equivalent in ap_setfileperms())
  
  Revision  Changes    Path
  1.7       +18 -29    apache-2.0/src/modules/dav/fs/repos.c
  
  Index: repos.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/dav/fs/repos.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- repos.c	2000/07/03 10:33:11	1.6
  +++ repos.c	2000/07/03 12:08:36	1.7
  @@ -444,10 +444,7 @@
       dst = ap_pstrcat(p, dst, "/", dst_file, NULL);
   
       /* copy/move the file now */
  -#if 0
  -    /* ### need st_dev from APR */
  -
  -    if (is_move && src_finfo.st_dev == dst_state_finfo.st_dev) {
  +    if (is_move && src_finfo.device == dst_state_finfo.device) {
   	/* simple rename is possible since it is on the same device */
   	if (rename(src, dst) != 0) {
   	    /* ### use something besides 500? */
  @@ -456,7 +453,6 @@
   	}
       }
       else
  -#endif
       {
   	/* gotta copy (and delete) */
   	return dav_fs_copymove_file(is_move, p, src, dst, pbuf);
  @@ -1093,37 +1089,33 @@
       }
   #endif
   
  -#if 0
  -    /* ### we need st_dev in ap_finfo_t */
  -
       /* determine whether a simple rename will work.
        * Assume source exists, else we wouldn't get called.
        */
  -    if (dstinfo->finfo.st_mode != 0) {
  -        /* ### APR does not expose the st_dev concept! */
  -	if (dstinfo->finfo.st_dev == srcinfo->finfo.st_dev) {
  +    if (dstinfo->finfo.protection != 0) {
  +	if (dstinfo->finfo.device == srcinfo->finfo.device) {
   	    /* target exists and is on the same device. */
   	    can_rename = 1;
   	}
       }
       else {
   	const char *dirpath;
  -	struct stat finfo;
  +	ap_finfo_t finfo;
   
   	/* destination does not exist, but the parent directory should,
   	 * so try it
   	 */
   	dirpath = ap_make_dirstr_parent(dstinfo->pool, dstinfo->pathname);
  -	if (stat(dirpath, &finfo) == 0
  -	    && finfo.st_dev == srcinfo->finfo.st_dev) {
  +	if (ap_stat(&finfo, dirpath, dstinfo->pool) == 0
  +	    && finfo.device == srcinfo->finfo.device) {
   	    can_rename = 1;
   	}
       }
  -#endif
   
  -    /* if we can't simply renamed, then do it the hard way... */
  +    /* if we can't simply rename, then do it the hard way... */
       if (!can_rename) {
  -        if ((err = dav_fs_copymove_resource(1, src, dst, DAV_INFINITY, response)) == NULL)
{
  +        if ((err = dav_fs_copymove_resource(1, src, dst, DAV_INFINITY,
  +                                            response)) == NULL) {
               /* update resource states */
               dst->exists = 1;
               dst->collection = src->collection;
  @@ -1887,11 +1879,13 @@
       }
   
       cdata = elem->first_cdata.first;
  -    f_cdata = elem->last_child == NULL
  +
  +    /* ### hmm. this isn't actually looking at all the possible text items */
  +    f_cdata = elem->first_child == NULL
   	? NULL
  -	: elem->last_child->following_cdata.first;
  +	: elem->first_child->following_cdata.first;
   
  -    /* DBG3("name=%s  cdata=%s  f_cdata=%s",elem->name,cdata ? cdata->text : "[null]",f_cdata
? f_cdata->text : "[null]"); */
  +    DBG3("name=%s  cdata=%s  f_cdata=%s",elem->name,cdata ? cdata->text : "[null]",f_cdata
? f_cdata->text : "[null]");
   
       if (cdata == NULL) {
   	if (f_cdata == NULL) {
  @@ -1923,7 +1917,7 @@
     too_long:
       return dav_new_error(resource->info->pool, HTTP_CONFLICT, 0,
   			 "The 'executable' property expects a single "
  -			 "character, valued 'T' or 'F'. The value submitted"
  +			 "character, valued 'T' or 'F'. The value submitted "
   			 "has too many characters.");
   
   }
  @@ -1941,6 +1935,7 @@
       /* assert: prop == executable. operation == SET. */
   
       /* don't do anything if there is no change. no rollback info either. */
  +    DBG2("new value=%d  (old=%d)", value, old_value);
       if (value == old_value)
   	return NULL;
   
  @@ -1948,15 +1943,12 @@
       if (value)
   	perms |= APR_UEXECUTE;
   
  -#if 0
  -    /* ### crap... APR does not have a chmod() ... skip for now. */
  -    if (chmod(resource->info->pathname, mode) == -1) {
  +    if (ap_setfileperms(resource->info->pathname, perms) != APR_SUCCESS) {
   	return dav_new_error(resource->info->pool,
   			     HTTP_INTERNAL_SERVER_ERROR, 0,
   			     "Could not set the executable flag of the "
   			     "target resource.");
       }
  -#endif
   
       /* update the resource and set up the rollback context */
       resource->info->finfo.protection = perms;
  @@ -1987,15 +1979,12 @@
       if (value)
   	perms |= APR_UEXECUTE;
   
  -#if 0
  -    /* ### crap... APR does not have a chmod() ... skip for now. */
  -    if (chmod(resource->info->pathname, mode) == -1) {
  +    if (ap_setfileperms(resource->info->pathname, perms) != APR_SUCCESS) {
   	return dav_new_error(resource->info->pool,
   			     HTTP_INTERNAL_SERVER_ERROR, 0,
   			     "After a failure occurred, the resource's "
   			     "executable flag could not be restored.");
       }
  -#endif
   
       /* restore the resource's state */
       resource->info->finfo.protection = perms;
  
  
  

Mime
View raw message