Skip to content

Commit

Permalink
Fixed zz_packagesmanager_reenabler.py reloading twice on starup.
Browse files Browse the repository at this point in the history
  • Loading branch information
evandrocoan committed Oct 23, 2018
1 parent cd54dad commit d7347fa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions 2_bootstrap.py
Expand Up @@ -49,6 +49,16 @@
from .package_control import loader, text, sys_path


def compare_text_with_file(input_text, file):
"""
Return `True` when the provided text and the `file` contents are equal.
"""

with open( file, "r", encoding='utf-8' ) as file:
text = file.read()
return input_text == text


def _background_bootstrap(settings):
"""
Runs the bootstrap process in a thread since it may need to block to update
Expand Down Expand Up @@ -203,10 +213,12 @@ def _delayed_in_progress_removal(package_name):

packages_directory = os.path.dirname( PACKAGE_ROOT_DIRECTORY )
reenable_package_code = dedent(reenable_package_code).lstrip()
reloader_package_file = os.path.join( packages_directory, "zz_packagesmanager_reenabler.py" )
reenable_package_file = os.path.join( packages_directory, "zz_packagesmanager_reenabler.py" )

if not compare_text_with_file(reenable_package_code, reenable_package_file):

with open( reloader_package_file, 'w', newline='\n', encoding='utf-8' ) as output_file:
output_file.write( reenable_package_code )
with open( reenable_package_file, 'w', newline='\n', encoding='utf-8' ) as output_file:
output_file.write( reenable_package_code )

base_loader_code = r"""
import sys
Expand Down
2 changes: 1 addition & 1 deletion package-metadata.json
@@ -1,5 +1,5 @@
{
"version": "2018.0019.1933",
"version": "2018.0022.1518",
"url": "https://packagecontrol.io",
"description": "A full-featured package manager",
"sublime_text": "*",
Expand Down

0 comments on commit d7347fa

Please sign in to comment.