Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Limit checks to filesize #27

Closed
secharly opened this Issue Sep 27, 2012 · 3 comments

Comments

Projects
None yet
2 participants

This is a great product, however sometimes we are required to open semi large files (1MB+), this plugin seems to cause sublime to slow down. What would be great is a setting to limit checking the source control by file size. For a work around now we have change the following Under DiffCommand -> run

def run(self, edit):
        vcs = get_vcs(self.get_working_dir())
        filename = os.path.basename(self.view.file_name())
        get_command = getattr(self, '{0}_diff_command'.format(vcs['name']), None)
        if get_command:
            self.run_command(get_command(filename), self.diff_done)
  • to -
def run(self, edit):
        vcs = get_vcs(self.get_working_dir())
        filename = os.path.basename(self.view.file_name())
        if self.view.size() > 200000:
            return
        get_command = getattr(self, '{0}_diff_command'.format(vcs['name']), None)
        if get_command:
            self.run_command(get_command(filename), self.diff_done)
Owner

gornostal commented Sep 28, 2012

I will add an extra option to set the maximum file size.

@gornostal gornostal closed this in 091ac4c Oct 2, 2012

secharly commented Oct 4, 2012

First the change is great and thanks for getting it out so quickly. However there appears to be a small bug at least ib my environment). I had to change

        filename = os.path.basename(self.view.file_name())
        max_file_size = settings.get('max_file_size', 1024) * 1024
        if not os.path.exists(filename) or os.path.getsize(filename) > max_file_size:
            # skip large files
  • to -
        filepath = self.view.file_name()
        filename = os.path.basename(filepath)
        max_file_size = settings.get('max_file_size', 1024) * 1024
        if not os.path.exists(filepath) or os.path.getsize(filepath) > max_file_size:
            # skip large files

As it appears it needed the full path as it was not properly finding the path to the file.

Owner

gornostal commented Oct 4, 2012

Hm.. Okay. I will change that. Thanks for noticing.

@gornostal gornostal reopened this Oct 5, 2012

@gornostal gornostal closed this in 897b355 Oct 5, 2012

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