bugranger - Bugs: bug #42736, Sorting by size causes crash

 
 

bug #42736: Sorting by size causes crash

Submitted by:  None
Submitted on:  Sat 12 Jul 2014 12:03:01 AM UTC  
 
Severity: 3 - NormalStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 22 Aug 2014 09:37:46 PM UTC, comment #1:

I applied your patch, thank you!

Roman Z. <hut>
Project Administrator
Sat 12 Jul 2014 12:03:01 AM UTC, original submission:

"chain set sort=size" causes ranger to crash using 1.6.1.77.g8061eb4

ranger version: 1.6.1, executed with python 3.4.1
Locale: en_US.UTF-8
Current file: /home/woop/downloads
Traceback (most recent call last):
File "/usr/lib/python3.4/site-packages/ranger/core/main.py", line 139, in main
fm.loop()
File "/usr/lib/python3.4/site-packages/ranger/core/fm.py", line 312, in loop
ui.redraw()
File "/usr/lib/python3.4/site-packages/ranger/gui/ui.py", line 265, in redraw
self.draw()
File "/usr/lib/python3.4/site-packages/ranger/gui/ui.py", line 291, in draw
DisplayableContainer.draw(self)
File "/usr/lib/python3.4/site-packages/ranger/gui/displayable.py", line 246, in draw
displayable.draw()
File "/usr/lib/python3.4/site-packages/ranger/gui/widgets/browserview.py", line 98, in draw
DisplayableContainer.draw(self)
File "/usr/lib/python3.4/site-packages/ranger/gui/displayable.py", line 246, in draw
displayable.draw()
File "/usr/lib/python3.4/site-packages/ranger/gui/widgets/browsercolumn.py", line 152, in draw
or self.target.sort_if_outdated() \
File "/usr/lib/python3.4/site-packages/ranger/container/directory.py", line 432, in sort_if_outdated
self.sort()
File "/usr/lib/python3.4/site-packages/ranger/container/directory.py", line 361, in sort
self.files_all.sort(key = sort_func)
File "/usr/lib/python3.4/site-packages/ranger/container/directory.py", line 80, in <lambda>
'size': lambda path: -path.size,
TypeError: bad operand type for unary -: 'NoneType'

Fixed by patching line 80 in ranger/container/directory.py:

@@ -77,7 +77,7 @@ class Directory(FileSystemObject, Accumulator, Loadable):
sort_dict = {
'basename': sort_by_basename,
'natural': sort_naturally,
- 'size': lambda path: -path.size,
+ 'size': lambda path: -(path.size or 1),
'mtime': lambda path: -(path.stat and path.stat.st_mtime or 1),
'ctime': lambda path: -(path.stat and path.stat.st_ctime or 1),
'atime': lambda path: -(path.stat and path.stat.st_atime or 1),

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by hut (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 22 Aug 2014 09:37:46 PM UTChutStatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1