* When a network node is uploading a spool file, receive it in ./network/spooltmp...
authorArt Cancro <ajc@citadel.org>
Tue, 18 May 2010 19:16:52 +0000 (19:16 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 18 May 2010 19:16:52 +0000 (19:16 +0000)
citadel/file_ops.c
citadel/modules/network/serv_network.c

index 0a790832aeb931069a9929f3f8824decff45699a..0438b244e2870ff6625baa56cdcd58278cc78c20 100644 (file)
@@ -569,6 +569,7 @@ void cmd_ucls(char *cmd)
 {
        FILE *fp;
        char upload_notice[512];
+       static int seq = 0;
 
        if (CC->upload_fp == NULL) {
                cprintf("%d You don't have an upload file open.\n", ERROR + RESOURCE_NOT_OPEN);
@@ -582,7 +583,27 @@ void cmd_ucls(char *cmd)
                CC->upload_type = UPL_FILE;
                cprintf("%d Upload completed.\n", CIT_OK);
 
-               /* FIXME ... here we need to trigger a network run */
+               if (CC->upload_type == UPL_NET) {
+                       char final_filename[PATH_MAX];
+                       snprintf(final_filename, sizeof final_filename,
+                               "%s/%s.%04lx.%04x",
+                               ctdl_netin_dir,
+                               CC->net_node,
+                               (long)getpid(),
+                               ++seq
+                       );
+
+                       if (link(CC->upl_path, final_filename) == 0) {
+                               unlink(CC->upl_path);
+                       }
+                       else {
+                               CtdlLogPrintf(CTDL_ALERT, "Cannot link %d to %d: %s\n",
+                                       CC->upl_path, final_filename, strerror(errno)
+                               );
+                       }
+
+                       /* FIXME ... here we need to trigger a network run */
+               }
 
                return;
        }
index fa50506609dfe7839fdf83cb707ae5ed89c81c62..a8c16a7a45fbd328e119dc125d7b0baa5e27ed56 100644 (file)
@@ -1974,17 +1974,18 @@ void transmit_spool(int *sock, char *remote_nodename)
 
 ABORTUPL:
        close(fd);
-       /** Last chance for shutdown exit */
+
+       /* Last chance for shutdown exit */
        if(CtdlThreadCheckStop())
                return;
                
        if (sock_puts(sock, "UCLS 1") < 0) return;
-       /**
+
+       /*
         * From here on we must complete or messages will get lost
         */
        if (sock_getln(sock, buf, sizeof buf) < 0) return;
-       CtdlLogPrintf(CTDL_NOTICE, "Sent %ld octets to <%s>\n",
-                       bytes_written, remote_nodename);
+       CtdlLogPrintf(CTDL_NOTICE, "Sent %ld octets to <%s>\n", bytes_written, remote_nodename);
        CtdlLogPrintf(CTDL_DEBUG, "<%s\n", buf);
        if (buf[0] == '2') {
                CtdlLogPrintf(CTDL_DEBUG, "Removing <%s>\n", sfname);