Bug 49881 - file time differs by 1 hour
Summary: file time differs by 1 hour
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: fish (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Jörg Walter
URL:
Keywords:
: 121636 125783 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-10-29 16:34 UTC by Stefan A. Möller
Modified: 2006-11-04 15:26 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
screenshot (52.22 KB, image/png)
2002-10-29 16:34 UTC, Stefan A. Möller
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan A. Möller 2002-10-29 16:34:21 UTC
Version:           1.1.2 (using KDE KDE 3.0.4)
Installed from:    SuSE RPMs
OS:          Linux

File times in fish are 1 hour behind the file times in a ssh shell.
Comment 1 Stefan A. Möller 2002-10-29 16:34:57 UTC
Created attachment 317 [details]
screenshot
Comment 2 Thiago Macieira 2003-01-16 20:59:15 UTC
I can confirm the situation. File times are always shown in GMT for fish. I tested that 
by connecting to a system at GMT-3, while myself I am at GMT+1. 
 
The problem occurs on 3.1 RC6. 
Comment 3 Willy De la Court 2003-03-16 15:53:33 UTC
Just commited a fix to solve this bug 
RCS file: /home/kde/kdebase/kioslave/fish/fish.cpp,v 
retrieving revision 1.21 
diff -u -p -r1.21 fish.cpp 
--- fish.cpp    5 Mar 2003 14:29:21 -0000       1.21 
+++ fish.cpp    16 Mar 2003 14:51:38 -0000 
@@ -244,7 +244,7 @@ fishProtocol::fishProtocol(const QCStrin 
     sendLen = -1; 
     connectionAuth.keepPassword = true; 
     connectionAuth.url.setProtocol("fish"); 
-    epoch.setTime_t(0); 
+    epoch.setTime_t(0, Qt::UTC); 
     outBufPos = -1; 
     outBuf = NULL; 
     outBufLen = 0; 
 
Comment 4 Jörg Walter 2003-03-21 10:18:08 UTC
*** Bug has been marked as fixed ***.
Comment 5 Ferdinand Gassauer 2005-02-06 20:25:10 UTC
current CVS of today, displays UTC instead of Timezone of user, who logged in

both boxes run at UTC time the users have CET as TZ and KDE setting
Comment 6 Ferdinand Gassauer 2005-02-06 20:26:10 UTC
BTW sftp displays the time correctly
Comment 7 Nicolas Goutte 2005-09-17 13:07:21 UTC
The fish KIO salve assumes the same local time locally than on the remote computer. (May be it is an error/drawback of the specification of the FISH protocol.)

(As for "seconds to epoch" errors, there are still some in code too.)

Have a nice day!
Comment 8 Nicolas Goutte 2005-09-17 13:29:54 UTC
SVN commit 461343 by goutte:

Be more careful about local time, UTC and seconds since epoch
(That is only locally, as the FISH protocol assume local time, which is bad.)
CCBUG:49881
(Not tested)


 M  +3 -6      fish.cpp  
 M  +0 -2      fish.h  


--- branches/KDE/3.5/kdebase/kioslave/fish/fish.cpp #461342:461343
@@ -273,7 +273,6 @@
     setMultipleAuthCaching( true );
     connectionAuth.keepPassword = true;
     connectionAuth.url.setProtocol("fish");
-    epoch.setTime_t(0, Qt::UTC);
     outBufPos = -1;
     outBuf = NULL;
     outBufLen = 0;
@@ -768,9 +767,7 @@
 
 int fishProtocol::makeTimeFromLs(const QString &monthStr, const QString &dayStr, const QString &timeyearStr)
 {
-    QDateTime dt;
-    dt.setTime_t(time(0));
-    dt.setTime(QTime());
+    QDateTime dt(QDate::currentDate(Qt::UTC));
     int year = dt.date().year();
     int month = dt.date().month();
     int currentMonth = month;
@@ -797,7 +794,7 @@
     }
     dt.date().setYMD(year,month,day);
 
-    return epoch.secsTo(dt);
+    return dt.toTime_t();
 }
 
 /**
@@ -929,7 +926,7 @@
                     if (pos < 0 || pos2 < 0 || pos3 < 0) break;
                     dt.setTime(QTime(line.mid(pos+1,pos2-pos-1).toInt(),line.mid(pos2+1,pos3-pos2-1).toInt(),line.mid(pos3+1).toInt()));
                     errorCount--;
-                    atom.m_long = epoch.secsTo(dt);
+                    atom.m_long = dt.toTime_t();
                     udsEntry.append(atom);
                     break;
 
--- branches/KDE/3.5/kdebase/kioslave/fish/fish.h #461342:461343
@@ -171,8 +171,6 @@
   /** number of bytes read so far */
   int dataRead;
   time_t t_last, t_start;
-  /** unix timestamp "0" as QDateTime */
-  QDateTime epoch;
   /** details about each fishCommand */
   static const struct fish_info {
       const char *command;
Comment 9 Nicolas Goutte 2005-09-17 13:30:58 UTC
SVN commit 461344 by goutte:

Be more careful about local time, UTC and seconds since epoch
(That is only locally, as the FISH protocol assume local time, which is bad.)
CCBUG:49881
(Foreward port of revision 461343; might not compile; not tested)


 M  +3 -6      fish.cpp  
 M  +0 -2      fish.h  


--- trunk/KDE/kdebase/kioslave/fish/fish.cpp #461343:461344
@@ -262,7 +262,6 @@
     setMultipleAuthCaching( true );
     connectionAuth.keepPassword = true;
     connectionAuth.url.setProtocol("fish");
-    epoch.setTime_t(0, Qt::UTC);
     outBufPos = -1;
     outBuf = NULL;
     outBufLen = 0;
@@ -753,9 +752,7 @@
 
 int fishProtocol::makeTimeFromLs(const QString &monthStr, const QString &dayStr, const QString &timeyearStr)
 {
-    QDateTime dt;
-    dt.setTime_t(time(0));
-    dt.setTime(QTime());
+    QDateTime dt(QDate::currentDate(Qt::UTC));
     int year = dt.date().year();
     int month = dt.date().month();
     int currentMonth = month;
@@ -782,7 +779,7 @@
     }
     dt.date().setYMD(year,month,day);
 
-    return epoch.secsTo(dt);
+    return dt.toTime_t();
 }
 
 /**
@@ -914,7 +911,7 @@
                     if (pos < 0 || pos2 < 0 || pos3 < 0) break;
                     dt.setTime(QTime(line.mid(pos+1,pos2-pos-1).toInt(),line.mid(pos2+1,pos3-pos2-1).toInt(),line.mid(pos3+1).toInt()));
                     errorCount--;
-                    atom.m_long = epoch.secsTo(dt);
+                    atom.m_long = dt.toTime_t();
                     udsEntry.append(atom);
                     break;
 
--- trunk/KDE/kdebase/kioslave/fish/fish.h #461343:461344
@@ -173,8 +173,6 @@
   /** number of bytes read so far */
   int dataRead;
   time_t t_last, t_start;
-  /** unix timestamp "0" as QDateTime */
-  QDateTime epoch;
   /** details about each fishCommand */
   static const struct fish_info {
       const char *command;
Comment 10 Tommi Tervo 2006-02-09 09:55:53 UTC
*** Bug 121636 has been marked as a duplicate of this bug. ***
Comment 11 Thiago Macieira 2006-02-10 22:46:24 UTC
Still displaying in UTC.
Comment 12 Tommi Tervo 2006-04-18 08:51:47 UTC
*** Bug 125783 has been marked as a duplicate of this bug. ***
Comment 13 Martin Koller 2006-11-04 15:26:56 UTC
SVN commit 601882 by mkoller:

BUG: 49881

set kio_fish's timezone to UTC so that mktime (used by QDateTime.toTime_t())
interprets the struct tm really in UTC


 M  +2 -0      fish.cpp  
 M  +10 -9     fish.pl  


--- branches/KDE/3.5/kdebase/kioslave/fish/fish.cpp #601881:601882
@@ -135,6 +135,8 @@
         exit(-1);
     }
 
+    setenv("TZ", "UTC", true);
+
     struct sigaction act;
     memset(&act,0,sizeof(act));
     act.sa_handler = ripper;
--- branches/KDE/3.5/kdebase/kioslave/fish/fish.pl #601881:601882
@@ -12,7 +12,7 @@
 use Fcntl;
 
 $|++;
-#open(DEBUG,">/tmp/kio_fish.debug.$$.log");
+open(DEBUG,">/tmp/kio_fish.debug.$$.log");
 # save code in initial directory if just transferred
 if (defined $code) {
     unlink('.fishsrv.pl');
@@ -42,7 +42,7 @@
     chomp;
     chomp;
     next if !length($_) || substr($_,0,1) ne '#';
-#    print DEBUG "$_\n";
+    print DEBUG "$_\n";
     s/^#//;
     /^VER / && do {
         # We do not advertise "append" capability anymore, as "write" is
@@ -74,7 +74,7 @@
             sysopen(OFH,$fn,O_WRONLY|O_CREAT|O_TRUNC) || do { close(FH); print "### 500 $!\n"; next; };
             local $/ = undef;
             my $buffer = '';
-            while ($size > 16384 && ($read = sysread(FH,$buffer,16384)) > 0) {
+            while ($size > 32768 && ($read = sysread(FH,$buffer,32768)) > 0) {
                 $size -= $read;
                 if (syswrite(OFH,$buffer,$read) != $read) {
                     close(FH); close(OFH);
@@ -254,13 +254,13 @@
     print "### 100\n";
     my $buffer = '';
     my $read = 1;
-    while ($size > 16384 && ($read = sysread(FH,$buffer,16384)) > 0) {
-#        print DEBUG "$size left, $read read\n";
+    while ($size > 32768 && ($read = sysread(FH,$buffer,32768)) > 0) {
+        print DEBUG "$size left, $read read\n";
         $size -= $read;
         print $buffer;
     }
     while ($size > 0 && ($read = sysread(FH,$buffer,$size)) > 0) {
-#        print DEBUG "$size left, $read read\n";
+        print DEBUG "$size left, $read read\n";
         $size -= $read;
         print $buffer;
     }
@@ -280,6 +280,7 @@
 sub write_loop {
     my $size = int($_[0]);
     my $fn = unquote($_[1]);
+        print DEBUG "write_loop called $size size, $fn fn, $_[2]\n";
     my $error = '';
     sysopen(FH,$fn,$_[2]) || do { print "### 400 $!\n"; return; };
     eval { flock(FH,2); };
@@ -290,13 +291,13 @@
     print "### 100\n";
     my $buffer = '';
     my $read = 1;
-    while ($size > 16384 && ($read = read(STDIN,$buffer,16384)) > 0) {
-#        print DEBUG "$size left, $read read\n";
+    while ($size > 32768 && ($read = read(STDIN,$buffer,32768)) > 0) {
+        print DEBUG "$size left, $read read\n";
         $size -= $read;
         $error ||= $! if (syswrite(FH,$buffer,$read) != $read);
     }
     while ($size > 0 && ($read = read(STDIN,$buffer,$size)) > 0) {
-#        print DEBUG "$size left, $read read\n";
+        print DEBUG "$size left, $read read\n";
         $size -= $read;
         $error ||= $! if (syswrite(FH,$buffer,$read) != $read);
     }