Bug 103729 - wrong file size reported (affects only one of more files!?)
Summary: wrong file size reported (affects only one of more files!?)
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: sftp (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Dawit Alemayehu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-12 15:49 UTC by Thomas Bettler
Modified: 2005-05-05 13:47 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
sftp34.diff (27.19 KB, text/x-diff)
2005-04-26 20:13 UTC, Dawit Alemayehu
Details
103729.diff (1.88 KB, text/x-diff)
2005-04-27 22:55 UTC, Dawit Alemayehu
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Bettler 2005-04-12 15:49:57 UTC
Version:            (using KDE KDE 3.4.0)
Installed from:    Gentoo Packages
OS:                Linux

Instead of 6061145769 bytes (in console client; or ssh remote ls -l) there are 1766178473 bytes reported. Fatal misbehaviour - whats up?
Comment 1 Thomas Bettler 2005-04-18 20:05:03 UTC
Already the second time I get this strange behaviour, this time on another file. via sftp or ssh the correct size is 5401559040 bytes
but kio_sftp reports 1106591744 bytes.

Fatal misbehaviour.
Comment 2 Thomas Bettler 2005-04-21 13:21:51 UTC
Seems to be the 2^32 bit limit that loops the size.
Instead of the acutal size, SIZE % 2^32 is reported

The same limit exists for the kio_smb handler:
http://bugs.kde.org/show_bug.cgi?id=92765
Comment 3 Thomas Bettler 2005-04-21 13:34:15 UTC
Duplicate report for kio_smb:
http://bugs.kde.org/show_bug.cgi?id=85653
Comment 4 Thomas Bettler 2005-04-21 13:37:22 UTC
Annotation:
The file size works correctly for kio_file and kio_fish, but fish doesn't give me the ability to resume uploads since it doesn't support *.part
Comment 5 Thomas Bettler 2005-04-21 17:08:07 UTC
Update: kio_ftp also displays the size correct.
Comment 6 Dawit Alemayehu 2005-04-26 20:13:34 UTC
Is there anyway you can try the attached patch and see if it fixes your 
problem ?

On Monday 18 April 2005 14:05, Thomas Bettler wrote:
[bugs.kde.org quoted mail]


Created an attachment (id=10802)
sftp34.diff
Comment 7 Dawit Alemayehu 2005-04-26 23:47:31 UTC
CVS commit by adawit: 

- Fix problem with symlinks not being clickable randomly.
- Fix the out of memory problem on x64 platforms.
- Fix wrong file size being reported for really large files.

BUGS:99928
BUGS:102103
BUGS:103729 


  M +290 -265  kio_sftp.cpp   1.65
  M +24 -23    sftpfileattr.cpp   1.16
  M +12 -14    sftpfileattr.h   1.12
Comment 8 Thomas Bettler 2005-04-27 01:28:05 UTC
I'm sorry to report that, but I just compiled kio_sftp from cvs and the size is still reported wrong. But anyway thanks a lot for your fixing and your assistance.
Comment 9 Thomas Bettler 2005-04-27 20:49:30 UTC
I'm sorry to report that, but I just compiled kio_sftp from cvs and the size is still reported wrong. (Forgot to reopen it)
Comment 10 Dawit Alemayehu 2005-04-27 22:55:28 UTC
Can you please try the attached patch and see if it solves the problem for 
you ?

On Wednesday 27 April 2005 14:49, Thomas Bettler wrote:
[bugs.kde.org quoted mail]


Created an attachment (id=10819)
103729.diff
Comment 11 Thomas Bettler 2005-04-28 02:40:16 UTC
I just tried it. This patch rocks! And fixes the size issue!
Thank you for your hard work. I'm really glad now.

You may close this bug.
Comment 12 Dawit Alemayehu 2005-04-28 17:08:33 UTC
CVS commit by adawit: 

- Real fix for the incorrect size reported for really big files.

BUGS:103729


  M +12 -13    sftpfileattr.cpp   1.18


--- kdebase/kioslave/sftp/sftpfileattr.cpp  #1.17:1.18
@@ -156,7 +156,6 @@ QDataStream& operator>> (QDataStream& s,
     fa.clear();
 
-    QByteArray fn;
-    Q_ULLONG size;
     if( fa.mDirAttrs ) {
+        QByteArray fn;
         s >> fn;
 
@@ -165,20 +164,18 @@ QDataStream& operator>> (QDataStream& s,
 
         s >> fa.mLongname;
-        size = fa.mLongname.size();
-        fa.mLongname.resize(size+1);
-        fa.mLongname[size] = 0;
-        //kdDebug() << ">> sftpfileattr filename (" << fa.mFilename.size() << ")= " << fa.mFilename <<  endl;
+        fa.mLongname.truncate( fa.mLongname.size() );
+        //kdDebug() << ">>: ftpfileattr long filename (" << fa.mLongname.size() << ")= " << fa.mLongname <<  endl;
     }
 
-    Q_UINT32 x;
     s >> fa.mFlags;  // get flags
 
     if( fa.mFlags & SSH2_FILEXFER_ATTR_SIZE ) {
-        // since we don't have a 64 bit int, ignore the top byte.
-        // Very bad if we get a > 2^32 size
-        s >> x;
-        s >> x; fa.setFileSize(x);
+        Q_ULLONG fileSize;
+        s >> fileSize;
+        fa.setFileSize(fileSize);
     }
 
+    Q_UINT32 x;
+
     if( fa.mFlags & SSH2_FILEXFER_ATTR_UIDGID ) {
         s >> x; fa.setUid(x);
@@ -186,6 +183,7 @@ QDataStream& operator>> (QDataStream& s,
     }
 
-    if( fa.mFlags & SSH2_FILEXFER_ATTR_PERMISSIONS )
-        { s >> x; fa.setPermissions(x); }
+    if( fa.mFlags & SSH2_FILEXFER_ATTR_PERMISSIONS ) {
+        s >> x; fa.setPermissions(x);
+    }
 
     if( fa.mFlags & SSH2_FILEXFER_ATTR_ACMODTIME ) {
Comment 13 Dawit Alemayehu 2005-05-05 13:47:58 UTC
*** Bug 105114 has been marked as a duplicate of this bug. ***