Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Mar 18, 2019. It is now read-only.
This repository was archived by the owner on Mar 18, 2019. It is now read-only.

OSError: Invalid cross-device link #176

Copy link
Copy link
@frague59

Description

@frague59
Issue body actions

Hi,

I'm using coreapi / coreapi-cli on a debian machine, and I'm having the following error on getting a schema:

$ coreapi get http://localhost:8001/
Traceback (most recent call last):
  File "/home/<user>/<project_root>/virtualenv/bin/coreapi", line 11, in <module>
    sys.exit(client())
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/coreapi_cli/main.py", line 147, in get
    doc = client.get(url, force_codec=force_codec)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/coreapi/client.py", line 136, in get
    return transport.transition(link, decoders, force_codec=force_codec)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/coreapi/transports/http.py", line 380, in transition
    result = _decode_result(response, decoders, force_codec)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/coreapi/transports/http.py", line 294, in _decode_result
    result = codec.load(response.content, **options)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/coreapi/codecs/base.py", line 24, in load
    return self.decode(*args, **kwargs)
  File "/home/<user>/<project_root>/virtualenv/lib/python3.6/site-packages/coreapi/codecs/download.py", line 143, in decode
    os.rename(temp_path, output_path)
OSError: [Errno 18] Invalid cross-device link: '/tmp/tmpjthickut.download' -> '/home/<user>/.coreapi/downloads/api-schema'

The problem is that you use os.rename(<src>, <dest>) , which performs a "link" copy.
The resolution is easy: you just have to replace the:

    os.rename(temp_path, output_path)

by:

    shutil.move(temp_path, output_path)

shutil is in the python standart library, so you have just to adds the import.

Thanks for this great tool !

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.