diff options
author | Timo Sirainen <cras@irssi.org> | 2002-10-14 15:26:26 +0000 |
---|---|---|
committer | cras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2002-10-14 15:26:26 +0000 |
commit | 55c2e7a066e700e23e15ba9f90d2aa02118b27dd (patch) | |
tree | b718ad720f46afbba1299e468719c3fb98df0455 /src/irc/dcc | |
parent | 4ed5e9adf6a353625b956c167188ecd3b1b11de2 (diff) | |
download | irssi-55c2e7a066e700e23e15ba9f90d2aa02118b27dd.zip |
/SET dcc_file_create_mode wasn't used. Also print strerror() message if
creation fails.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@2949 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/irc/dcc')
-rw-r--r-- | src/irc/dcc/dcc-get.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/irc/dcc/dcc-get.c b/src/irc/dcc/dcc-get.c index d9529553..e8847698 100644 --- a/src/irc/dcc/dcc-get.c +++ b/src/irc/dcc/dcc-get.c @@ -176,7 +176,7 @@ static void sig_dccget_connected(GET_DCC_REC *dcc) { struct stat statbuf; char *fname, *tempfname; - int ret, temphandle, old_umask; + int ret, ret_errno, temphandle, old_umask; if (net_geterror(dcc->handle) != 0) { /* error connecting */ @@ -211,14 +211,18 @@ static void sig_dccget_connected(GET_DCC_REC *dcc) if download_path is in some global temp directory */ tempfname = g_strconcat(dcc->file, ".XXXXXX", NULL); - old_umask = umask(066); + old_umask = umask(0077); temphandle = mkstemp(tempfname); - umask(old_umask); + umask(old_umask); if (temphandle == -1) ret = -1; - else { + else + ret = fchmod(temphandle, dcc_file_create_mode); + + if (ret != -1) { ret = link(tempfname, dcc->file); + if (ret == -1 && errno == EPERM) { /* hard links aren't supported - some people want to download stuff to FAT/NTFS/etc @@ -229,17 +233,17 @@ static void sig_dccget_connected(GET_DCC_REC *dcc) /* if ret = 0, we're the file owner now */ dcc->fhandle = ret == -1 ? -1 : - open(dcc->file, O_WRONLY | O_TRUNC, - dcc_file_create_mode); + open(dcc->file, O_WRONLY | O_TRUNC); - /* close/remove the temp file */ + /* close/remove the temp file */ + ret_errno = errno; close(temphandle); unlink(tempfname); g_free(tempfname); if (dcc->fhandle == -1) { - signal_emit("dcc error file create", 2, - dcc, dcc->file); + signal_emit("dcc error file create", 3, + dcc, dcc->file, g_strerror(ret_errno)); dcc_destroy(DCC(dcc)); return; } |