Skip to content

Conversation

@initumX
Copy link

@initumX initumX commented Jun 25, 2025

ISSUE TYPE

  • Improvement/feature implementation

RUNTIME ENVIRONMENT

ranger version: ranger-master
Python version: 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0]
Locale: en_US.UTF-8
Debian 12 "Bookworm"

CHECKLIST

  • [X ] The CONTRIBUTING document has been read [REQUIRED]
  • [ X] All changes follow the code style [REQUIRED]
  • [ X] All new and existing tests pass [REQUIRED]
  • [ X] Changes require config files to be updated
    • [ X] Config files have been updated
  • [X ] Changes require documentation to be updated
    • Documentation has been updated
  • Changes require tests to be updated
    • Tests have been updated

DESCRIPTION

  • added new setting max_archive_preview_size on rc.conf, it looks like this
    set max_archive_preview_size 20M
  • added this setting into ALLOWED_SETTINGS inside container/settings.pyfile like this:
    'max_archive_preview_size': str,
  • added parse_human_readable function into ext/human_readable.py file (used for parsing human readable option 20M and convert it into bytes)
  • added is_archive_preview_allowed function into container/file.py file. This function gets max_archive_preview_size from settings, compare its value with current file size and returns True or False
  • modified has_preview function from the same file. This is modified part:
if self.fm.settings.preview_script and \
                self.fm.settings.use_preview_script:
    if self.container:
        return self.is_archive_preview_allowed()
    return True

this self.is_archive_preview_allowed(self.path) returns true if max_archive_preview_size is blank or equal to zero or if its value is greater or equal to file size. So, nothing is broken. All these modifications affects only on "container" files and only if their size is greater than max_archive_preview_size (and only when preview script is used). In all other cases everything should work as worked before.

UPD:
Modified mkdir from commands.py. Now it can create multiple folders at once

MOTIVATION AND CONTEXT

#2984

@toonn
Copy link
Member

toonn commented Jun 26, 2025

Please split the mkdir changes into a separate PR.

@initumX
Copy link
Author

initumX commented Jun 26, 2025

I've deleted mkdir changings from this PR. Idk how to add it from new PR, it pushes everything here

@initumX
Copy link
Author

initumX commented Jun 28, 2025

lol, It appeared here again. I have no idea how does github work. This is just 30 lines of code, doing very simple job. No mistakes there. But one issue is there. This line self.fm.notify("Created directory: {0}".format(full_path)) shows only the last one created folder. If it's a problem, you can create a list created_dirs = [] and append a dirname there right after makedirs(full_path), like this
created_dirs.append(dirname) and then use it in fm.notify self.fm.notify("Created directories: {0}".format(created_dirs)). This way you can use mkdir like this:

:mkdir folder1/folder2 yetonefolder
mkdir folder3 folder4
mkdir folder5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants