Bug 143874 - wrong import session size
Summary: wrong import session size
Status: RESOLVED FIXED
Alias: None
Product: k3b
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Sebastian Trueg
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-05 13:44 UTC by John Floyd
Modified: 2007-04-11 16:12 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Fixes gui project sizes - fixes double dipping and fixes existing session sizes reports to console problem in debug output. (2.02 KB, patch)
2007-04-11 14:42 UTC, John Floyd
Details

Note You need to log in before you can comment on or make changes to this bug.
Description John Floyd 2007-04-05 13:44:22 UTC
Version:           1.0 (using KDE KDE 3.5.5)
Installed from:    SuSE RPMs
OS:                Linux

The calculation of the import seesion size is wrong.  It appears to be due to the treatment for 2 layer disks.  Looking at the code in k3bdevice.cpp, it seems that an allowance for single layer needs to be made - that is where the variable ea0 is zero.
The extract below shows that the diskinfo gives the correct sizes (520M) whilst the TOC calc is wrong.  Note that Last sec layer 1: 00:00:00 (LBA 0) (0 Bytes) - I think that this causes the problem.  

In the function K3bDevice::DiskInfo K3bDevice::Device::diskInfo()
the sizes are calculated with

	  K3b::Msf da0 = ea0 - sda + 1;
	  K3b::Msf da1 = eda - ea0;

but these are meaningless when ea0 zero.  as it appears that then Msf zeros a negative number which results for da0 when ea0 is zero.


Extract from console messages -

First sec data area: 43:41:33 (LBA 196608) (402653184
Last sec data area: 104:37:56 (LBA 470831) (964261888 Bytes)
Last sec layer 1: 00:00:00 (LBA 0) (0 Bytes)
Layer 1 length: 00:00:01 (LBA 1) (2048 Bytes)
Layer 2 length: 104:37:56 (LBA 470831) (964261888 Bytes)
DiskInfo:
Mediatype:       DVD-R Sequential
Current Profile: DVD-R Sequential
Disk state:      incomplete
Empty:           0
Rewritable:      0
Appendable:      1
Sessions:        1
Tracks:          1
Layers:          1
Capacity:        510:38:38 (LBA 2297888) (4706074624 Bytes)
Remaining size:  449:42:14 (LBA 2023664) (4144463872 Bytes)
Used Size:       60:56:24 (LBA 274224) (561610752 Bytes)
Comment 1 Daniel Eklöf 2007-04-06 19:34:06 UTC
I have noticed this too. I believe these lines are causing it (from K3bDataDoc::size() ):

  if( m_isoOptions.doNotCacheInodes() )
    return root()->blocks().mode1Bytes() + m_oldSessionSize;
  else

Unchecking the "Do not cache inodes" option makes k3b report the correct session size.
Comment 2 John Floyd 2007-04-11 14:42:30 UTC
Created attachment 20229 [details]
Fixes gui project sizes - fixes double dipping and fixes existing session sizes reports to console problem in debug output.

First patch appears to fix the double dipping in calculating the size of the
files in the project window.  It tests for existing imported files before
adding in its size.

The second patch fixes the incorrect size reporting shown in my original post. 
Not sure if this is actually used anywhere though.  The problem here is to
differentiate between single and double layer discs.
Comment 3 Sebastian Trueg 2007-04-11 16:12:08 UTC
Thanks a lot for your patch. I will apply the first one. The second one, however, seems not important since the output is only used for debugging anyway.
Comment 4 Sebastian Trueg 2007-04-11 16:12:56 UTC
SVN commit 652574 by trueg:

Do not count the size of items from the old session.

BUG: 143874


 M  +23 -21    k3bdiritem.cpp  


--- trunk/extragear/multimedia/k3b/libk3b/projects/datacd/k3bdiritem.cpp #652573:652574
@@ -1,4 +1,4 @@
-/* 
+/*
  *
  * $Id$
  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
@@ -35,7 +35,7 @@
     m_dirs(0)
 {
   m_k3bName = name;
-  
+
   // add automagically like a qlistviewitem
   if( parent() )
     parent()->addDataItem( this );
@@ -59,7 +59,7 @@
 K3bDirItem::~K3bDirItem()
 {
   // delete all children
-  // doing this by hand is much saver than using the 
+  // doing this by hand is much saver than using the
   // auto-delete feature since some of the items' destructors
   // may change the list
   K3bDataItem* i = m_children.first();
@@ -69,7 +69,7 @@
     takeDataItem(i);
     delete i;
     i = m_children.first();
-  }    
+  }
 
   // this has to be done after deleting the children
   // because the directory itself has a size of 0 in K3b
@@ -156,11 +156,11 @@
       updateFiles( -1, 0 );
 
     item->m_parentDir = 0;
-    
+
     // inform the doc
     if( doc() )
       doc()->itemRemovedFromDir( this, item );
-    
+
     if( item->isFile() ) {
       // restore the item imported from an old session
       if( static_cast<K3bFileItem*>(item)->replaceItemFromOldSession() )
@@ -234,7 +234,7 @@
 
 bool K3bDirItem::mkdir( const QString& dirPath )
 {
-  // 
+  //
   // An absolut path always starts at the root item
   //
   if( dirPath[0] == '/' ) {
@@ -334,21 +334,23 @@
 
 void K3bDirItem::updateSize( K3bDataItem* item, bool removed )
 {
-  if( removed ) {
-    m_followSymlinksSize -= item->itemSize( true );
-    m_size -= item->itemSize( false );
-    m_followSymlinksBlocks -= item->itemBlocks( true ).lba();
-    m_blocks -= item->itemBlocks( false ).lba();
-  }
-  else {
-    m_followSymlinksSize += item->itemSize( true );
-    m_size += item->itemSize( false );
-    m_followSymlinksBlocks += item->itemBlocks( true ).lba();
-    m_blocks += item->itemBlocks( false ).lba();
-  }
+    if ( !item->isFromOldSession() ) {
+        if( removed ) {
+            m_followSymlinksSize -= item->itemSize( true );
+            m_size -= item->itemSize( false );
+            m_followSymlinksBlocks -= item->itemBlocks( true ).lba();
+            m_blocks -= item->itemBlocks( false ).lba();
+        }
+        else {
+            m_followSymlinksSize += item->itemSize( true );
+            m_size += item->itemSize( false );
+            m_followSymlinksBlocks += item->itemBlocks( true ).lba();
+            m_blocks += item->itemBlocks( false ).lba();
+        }
+    }
 
-  if( parent() )
-    parent()->updateSize( item, removed );
+    if( parent() )
+        parent()->updateSize( item, removed );
 }
 
 void K3bDirItem::updateFiles( long files, long dirs )