Roxen.git/
server/
modules/
filesystems/
filesystem.pike
Branch:
Tag:
Non-build tags
All tags
No tags
2018-04-10
2018-04-10 09:04:38 by Karl Gustav Sterneberg <kg@roxen.com>
76b5cc25db11f1a2bd6609974f27a94fa8f3354e (
50
lines) (+
17
/-
33
)
[
Show
|
Annotate
]
Branch:
76b5cc25db11f1a2bd6609974f27a94fa8f3354e
Filesystem
[WebDAV]
: Fixed PUT renaming existing file.
1177:
return Roxen.http_status(403, "Permission denied."); }
-
SETUID_TRACE("Saving file", 0);
-
-
rm(norm_f);
-
// mkdirhier(norm_f);
-
-
if (id->misc->quota_obj) {
-
QUOTA_WERR("Checking if the file already existed.");
-
if (size > 0) {
-
QUOTA_WERR("Deallocating " + size + "bytes.");
-
id->misc->quota_obj->deallocate(URI, size);
-
}
-
}
-
-
object to = Stdio.File();
-
+
TRACE_ENTER("PUT: Accepted", 0);
-
if ((size > -1) && (< "Darwin", "Win32" >)[System.uname()->sysname]) {
-
// File exists, and we're on an OS where we assume a
-
// case insensitive filesystem.
-
//
-
// NB: At least MacOS X has the misbehavior of renaming
-
// preexisting files when opening with "wct".
-
//
-
// Avoid this by looking up the name from the filesystem.
-
TRACE
_
ENTER
(
sprintf(
"
Looking
up path %O in real filesystem.
",
norm_f),
0);
-
norm_f = Roxen.lookup_real_path_case_insens(norm_f, 1);
-
TRACE_LEAVE(sprintf("FOund path: %O\n", norm_f));
-
}
+
SETUID_
TRACE("
Saving
file
", 0);
-
/*
Clear
the
stat-cache for this file */
-
if
(
stat_cache
)
{
-
cache_set("stat_cache", norm_f, 0)
;
-
}
-
+
object
to
=
Stdio.File
();
if(!to->open(norm_f, "wct", 0666)) { int err = to->errno();
1225:
return 0; }
+
if (id->misc->quota_obj) {
+
QUOTA_WERR("Checking if the file already existed.");
+
if (size > 0) {
+
QUOTA_WERR("Deallocating " + size + "bytes.");
+
id->misc->quota_obj->deallocate(URI, size);
+
}
+
}
+
+
/* Clear the stat-cache for this file */
+
if (stat_cache) {
+
cache_set("stat_cache", norm_f, 0);
+
}
+
// FIXME: Race-condition. string msg = safe_chmod(norm_f, 0666 & ~(id->misc->umask || 022)); privs = 0;