aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorStefan Tomanek <stefan.tomanek@wertarbyte.de>2010-11-07 16:54:49 +0100
committerDaniel Stenberg <daniel@haxx.se>2010-11-10 10:43:05 +0100
commitf1db21218b35b618f622deb94b6e5ab2c62bbd17 (patch)
tree54673bd388300203faf724cf8034b2ce278014f0 /src/main.c
parent892cacef43b4871d8ce50b2e61a143ede1b3083e (diff)
write extended attributes by using fsetxattr
Instead of reopening the downloaded file, fsetxattr uses the (already open) file descriptor to attach extended attributes. This makes the procedure more robust against errors caused by moved or deleted files.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/main.c b/src/main.c
index deca6c979..2f81ef4e8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5633,9 +5633,17 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
}
}
}
-
if(outfile && !curlx_strequal(outfile, "-") && outs.stream) {
- int rc = fclose(outs.stream);
+ int rc;
+
+ if(config->xattr) {
+ rc = fwrite_xattr(curl, fileno(outs.stream) );
+ if(rc)
+ warnf(config, "Error setting extended attributes: %s\n",
+ strerror(errno) );
+ }
+
+ rc = fclose(outs.stream);
if(!res && rc) {
/* something went wrong in the writing process */
res = CURLE_WRITE_ERROR;
@@ -5643,13 +5651,6 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
}
}
- if(config->xattr && outs.filename) {
- int err = write_xattr(curl, outs.filename );
- if(err)
- warnf( config, "Error setting extended attributes: %s\n",
- strerror(errno) );
- }
-
#ifdef HAVE_UTIME
/* Important that we set the time _after_ the file has been
closed, as is done above here */