Merge remote-tracking branch 'mvo/bugfix/multiarch-upgrade' into debian/sid
[ntk/apt.git] / methods / ftp.cc
index 979adca..2d05364 100644 (file)
@@ -26,7 +26,6 @@
 
 #include <sys/stat.h>
 #include <sys/time.h>
-#include <utime.h>
 #include <unistd.h>
 #include <signal.h>
 #include <stdio.h>
@@ -953,14 +952,16 @@ void FtpMethod::SigTerm(int)
 {
    if (FailFd == -1)
       _exit(100);
-   close(FailFd);
-   
+
    // Timestamp
-   struct utimbuf UBuf;
-   UBuf.actime = FailTime;
-   UBuf.modtime = FailTime;
-   utime(FailFile.c_str(),&UBuf);
-   
+   struct timespec times[2];
+   times[0].tv_sec = FailTime;
+   times[1].tv_sec = FailTime;
+   times[0].tv_nsec = times[1].tv_nsec = 0;
+   futimens(FailFd, times);
+
+   close(FailFd);
+
    _exit(100);
 }
                                                                        /*}}}*/
@@ -1059,13 +1060,14 @@ bool FtpMethod::Fetch(FetchItem *Itm)
       if (Server->Get(File,Fd,Res.ResumePoint,Hash,Missing) == false)
       {
         Fd.Close();
-        
+
         // Timestamp
-        struct utimbuf UBuf;
-        UBuf.actime = FailTime;
-        UBuf.modtime = FailTime;
-        utime(FailFile.c_str(),&UBuf);
-        
+        struct timespec times[2];
+        times[0].tv_sec = FailTime;
+        times[1].tv_sec = FailTime;
+        times[0].tv_nsec = times[1].tv_nsec = 0;
+        futimens(FailFd, times);
+
         // If the file is missing we hard fail and delete the destfile
         // otherwise transient fail
         if (Missing == true) {
@@ -1077,20 +1079,21 @@ bool FtpMethod::Fetch(FetchItem *Itm)
       }
 
       Res.Size = Fd.Size();
+
+      // Timestamp
+      struct timespec times[2];
+      times[0].tv_sec = FailTime;
+      times[1].tv_sec = FailTime;
+      times[0].tv_nsec = times[1].tv_nsec = 0;
+      futimens(Fd.Fd(), times);
+      FailFd = -1;
    }
-   
+
    Res.LastModified = FailTime;
    Res.TakeHashes(Hash);
-   
-   // Timestamp
-   struct utimbuf UBuf;
-   UBuf.actime = FailTime;
-   UBuf.modtime = FailTime;
-   utime(Queue->DestFile.c_str(),&UBuf);
-   FailFd = -1;
 
    URIDone(Res);
-   
+
    return true;
 }
                                                                        /*}}}*/