Skip to content

ResourcePath.copytree fails for directory inside compressed package #134

@rchl

Description

@rchl

I have package LSP-eslint.sublime-package with file structure like:

/vscode-eslint/
/vscode-eslint/server.js
/vscode-eslint/more_files
/plugin.py

I'm trying to copy whole vscode-eslint directory to cache directory with:

source_resource_path = 'Packages/LSP-eslint/vscode-eslint/'
target_path = os.path.join(sublime.cache_path(), 'LSP-eslint', 'server')
sublime_lib.ResourcePath(source_resource_path).copytree(target_path, exist_ok=True)

That fails with:

Traceback (most recent call last):
  File "/Users/me/Library/Application Support/Sublime Text 3/Packages/sublime_lib/st3/sublime_lib/resource_path.py", line 521, in read_bytes
    return sublime.load_binary_resource(str(self))
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime.py", line 244, in load_binary_resource
    raise IOError('resource "%s" not found' % name)
OSError: resource "Packages/LSP-eslint/vscode-eslint" not found

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/Lib/python33/sublime_plugin.py", line 478, in on_api_ready
    plc()
  File "/Users/me/Library/Application Support/Sublime Text 3/Installed Packages/LSP-eslint.sublime-package/plugin.py", line 52, in plugin_loaded
    sublime_lib.ResourcePath(local_server_path).copytree(server_cache_directory_path, exist_ok=True)
  File "/Users/me/Library/Application Support/Sublime Text 3/Packages/sublime_lib/st3/sublime_lib/resource_path.py", line 608, in copytree
    resource.copy(file_path)
  File "/Users/me/Library/Application Support/Sublime Text 3/Packages/sublime_lib/st3/sublime_lib/resource_path.py", line 582, in copy
    data = self.read_bytes()
  File "/Users/me/Library/Application Support/Sublime Text 3/Packages/sublime_lib/st3/sublime_lib/resource_path.py", line 523, in read_bytes
    raise FileNotFoundError(str(self)) from err
FileNotFoundError: Packages/LSP-eslint/vscode-eslint

It works fine when package is unpacked.
It works (I believe) to get all subresources with .glob('**') and copy them one-by-one but it fails trying to copy contents of directory with copytree.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions