83 Commits

Author SHA1 Message Date
Sybren A. Stüvel
d778849c89 Add note about not supporting Shaman API of Flamenco 3.x
Decided to *not* support the Shaman API of Flamenco 3.x in BAT. The
support for that protocol will be implemented in the Flamenco 3.x add-on
for Blender, and not in BAT itself.

A future version of BAT will remove the Shaman API support altogether.
2022-03-25 11:55:30 +01:00
Sybren A. Stüvel
cd3f9ce671 Avoid late (non-top-level) imports
Avoiding late imports helps to isolate Blender add-ons bundling BAT from
each other.

There was one late/lazy import to avoid a dependency cycle. This was
solved by simply copying that one tiny function.
2022-03-11 17:03:08 +01:00
Sybren A. Stüvel
843c34c3c0 Support UDIM images 2022-02-18 16:12:41 +01:00
Ethan Simon
608a7bdac9 Compatibility with packing read-only source files
File permissions are no longer copied when packing. This means that
read-only source files can still be packed without errors, even when
they have to be rewritten (due to changed paths).

Reviewed by: sybren

Differential Revision: https://developer.blender.org/D13128
2021-11-09 11:15:20 +01:00
Sybren A. Stüvel
087ff25c76 Add 'strict pointer mode' to BlendFile
Add a 'strict pointer mode' to the `BlendFile` class, which is enabled
by default. This allows users of the `BlendFile` class to decide whether
a bad pointer (i.e. one that points to a non-existing datablock) returns
`None` or raises a `SegmentationFault` exception.
2021-07-22 10:28:48 +02:00
Sybren A. Stüvel
803c38dac1 Cleanup: reformat with Black 2021-07-22 10:14:43 +02:00
Sybren A. Stüvel
e4bf2e8e35 Improved path handling
This commit fixes a bunch of issues at the same time, as they are all
related to path handling:

- `pathlib.Path.resolve()` or `.absolute()` are replaced by
  `bpathlib.make_absolute()`. The latter does NOT follow symlinks and does
  NOT network mounts from a drive letter to UNC notation. This also has
  advantages on non-Windows sytems, as it allows BAT-packing a directory
  structure with symlinked files (such as a Shaman checkout).
- Better handling of drive letters, and of paths that cross drive
  boundaries.
- Better testing of Windows-specific cases when running the tests on
  Windows, and of POSIX-specific cases on other platforms.

Thanks to @wisaac for starting this patch in D6676.

Thanks to @jbakker for pointing out the drive letter issue. This fixes
T70655.
2020-03-17 17:15:19 +01:00
Sybren A. Stüvel
23643ace13 Remove unnecessary dictionary lookup
This may also fix a Windows compatibility issue related to path
normalisation. Untested as it's hard to reproduce, but at least it
shouldn't hurt either.
2019-09-27 12:20:15 +02:00
Sybren A. Stüvel
af63f9c3c8 Allow setting Shaman JWT token in SHAMAN_JWT_TOKEN environment variable
I also removed the unused `shaman/auth.py` file.
2019-09-24 11:49:48 +02:00
Sybren A. Stüvel
113b0c9bb8 Fix T65904: External files with same path on different drives are packed once
External files with the same path on different drives are packed as a
single file. In this commit the drive letter is taken into account when
determining the path inside `_outside_project`, so that they are distinct.
2019-06-26 14:37:29 +02:00
Sybren A. Stüvel
f40f7585ed Prevent error when modifying actions dict 2019-06-07 12:35:41 +02:00
Sybren A. Stüvel
37fc7f467a Fix exception when having project on a mapped network drive in Windows 2019-06-07 12:35:41 +02:00
Sybren A. Stüvel
acd5a18bed Import urllib3 from requests.packages.urllib3
This is for compatibility with Blender 2.79.
2019-04-18 12:04:03 +02:00
Sybren A. Stüvel
e9fcdb0191 Use exponential backoff when retrying HTTP connections 2019-03-06 16:21:30 +01:00
Sybren A. Stüvel
44ee553c0a Shaman: added some timeouts to HTTP requests 2019-03-06 16:00:46 +01:00
Sybren A. Stüvel
10abeaea49 Fix ValueError when not requesting a checkout 2019-03-06 12:10:55 +01:00
Sybren A. Stüvel
dabb249e9b Python 3.5 fixes
`typing.Deque` was introduced in Python 3.6, so we can only use it when
we no longer support Blender 2.79.
2019-03-01 15:12:24 +01:00
Sybren A. Stüvel
7a7304d7a3 Shaman: Include original filename when uploading file 2019-03-01 14:07:24 +01:00
Sybren A. Stüvel
a2f9a7b484 Shaman changed response does-not-existfile-unknown
Instead of 'does-not-exist' we'll now receive 'file-unknown' (see Shaman
commit 44efa6b39bddc703a14aa68316b092866813c38a)
2019-03-01 14:07:24 +01:00
Sybren A. Stüvel
b22b9da5d0 Shaman: Moved URL parsing into a separate function
This allows other code to just call that function, rather than copying
the behaviour.
2019-03-01 14:07:24 +01:00
Sybren A. Stüvel
f34bf7c66f When aborting, make sure the reason is available
This allows a GUI to display the reason of abortion.
2019-03-01 14:07:24 +01:00
Sybren A. Stüvel
6104bd6078 Shaman: Make checkout location available to the Packer 2019-03-01 14:07:24 +01:00
Sybren A. Stüvel
14417b2d73 Record bytes & files uploaded on Transferer 2019-03-01 14:07:24 +01:00
Sybren A. Stüvel
9074421ec3 Shaman server support
The Shaman server is a file storage system that identifies files by
SHA256sum and file length. BAT can send packs there by only uploading
changed/new files. The BAT pack is reproduced at the Shaman server's
checkout directory by creating symlinks to the files in its file
storage.

Retrying sending files:

When we can defer uploading a file (that is, when we have other files to
upload as well, and we could send the current file at a later moment) we
send an `X-Shaman-Can-Defer-Upload: true` header in the file upload
request. In that case, when someone else is already uploading that file,
a `208 Already Reported` response is sent and the connection is closed.
Python's Requests library unfortunately won't give us that response if
we're still streaming the request, and raise a ConnectionError exception
instead. This exception can mean two things:

- If the `X-Shaman-Can-Defer-Upload: true` header was sent: someone else
  is currently uploading that file, so defer it.
- If that header was not sent: that file is already completely uploaded
  and does not need to be uploaded again.

Instead of retrying each failed file, after a few failures we now just
resend the definition file to get a new list of files to upload, then
send those. This should considerably reduce the number of HTTP calls
when multiple clients are uploading the same set of files.
2019-03-01 14:07:24 +01:00
Sybren A. Stüvel
add5cf930b Include error message with error status 2019-02-26 16:35:55 +01:00
Sybren A. Stüvel
03fb4da583 Convert target path from Path to str & PurePath
The target path is just read as string from the CLI now, to allow more
complex targets (such as URLs) that don't directly map to a path.

The Packer subclass now handles the conversion from that string to a
`pathlib.PurePath`, and specific subclasses & transfer classes can convert
those to a `pathlib.Path` to perform actual filesystem operations when
necessary.
2019-02-26 16:35:08 +01:00
Sybren A. Stüvel
c4a0d5925a Use 'bat-' prefix when creating temporary directories 2019-02-26 16:35:08 +01:00
Sybren A. Stüvel
e9e1cfd8f5 Removed unused imports 2019-02-26 14:49:54 +01:00
Sybren A. Stüvel
ee29184b3c Removed unused FileCopierPool class 2019-02-04 15:34:29 +01:00
Sybren A. Stüvel
55a14eca1b Removed some extraneous commas 2019-02-04 15:17:14 +01:00
Sybren A. Stüvel
d222fea960 Explicitly write pack-info.txt as UTF-8 2019-01-02 15:14:50 +01:00
Sybren A. Stüvel
772a5a1b1c Replace → with ->
Apparently Windows still isn't using UTF-8 by default, and fails when
handling these log entries.
2019-01-02 15:14:50 +01:00
Sybren A. Stüvel
37ad8f8dfc Added --relative-only option to bat pack command
This makes BAT skip assets that are referred to with an absolute path.
It is assumed that the receiver of the BAT pack can access those assets
at the same path.
2018-12-06 10:02:14 +01:00
Sybren A. Stüvel
33512d42cf Multi-threaded compressed file transfers
For regular file transfers (so to a directory, not to a ZIP file or S3
storage), use multi-threaded transfer when compressing. Compressing is
CPU-bound, so using multiple threads speeds things up considerably
(packing a Spring lighting file went from 6min30 single-threaded to
2min13 multi-threaded on my machine).
2018-11-27 15:50:20 +01:00
Sybren A. Stüvel
521c7e1916 Added --compress option for 'bat pack' command
This compresses all packed Blend files. Other files, as well as already-
compressed Blend files, are left as-is.
2018-11-27 14:29:37 +01:00
Sybren A. Stüvel
38b3e2b55c Fixed a whole bunch of MyPy errors
New release of mypy picks up more.
2018-07-10 16:02:14 +02:00
Sybren A. Stüvel
0b96635953 Fix T55539: BAT doesn't pack particle caches 2018-07-03 15:05:15 +02:00
Sybren A. Stüvel
d103056558 Flush the Packer callback queue when closing 2018-07-03 13:01:36 +02:00
Sybren A. Stüvel
f1cfc28a1c Report skipped files 2018-07-03 13:00:10 +02:00
Sybren A. Stüvel
7fe06c247b Also report transfer progress on MOVE
Previously transfers were only reported when copying files.
2018-07-03 12:56:08 +02:00
Sybren A. Stüvel
dfa07e19cc Fix T55007: Support fluid simulation cache files
This also adds support for entire directory paths to be assets, in
addition to globs and numbered file sequences.
2018-06-05 15:12:10 +02:00
Sybren A. Stüvel
fc144138d0 Better transfer error handling 2018-06-05 15:12:10 +02:00
Sybren A. Stüvel
44c4ce3a69 Speed up packing
The .get() function raises a queue.Empty exception anyway, so there was
no real need for the .empty() call. Furthermore, it turned out to really
slow things down.
2018-06-05 15:12:10 +02:00
Sybren A. Stüvel
099d51c4ff Slightly slower flushing/queue checking on the main thread 2018-03-26 17:14:10 +02:00
Sybren A. Stüvel
85840faf70 Added docstring 2018-03-22 10:10:50 +01:00
Sybren A. Stüvel
8d1bd89583 Allow packing to ZIP files 2018-03-22 10:06:48 +01:00
Sybren A. Stüvel
e53470d898 Add a pack-info.txt file at the top of the BAT Pack
This file explains which blend file this pack was created for.
2018-03-21 16:33:41 +01:00
Sybren A. Stüvel
3a3dbb5042 Added TODO 2018-03-20 18:13:16 +01:00
Sybren A. Stüvel
1111465061 Report progress of S3 uploads while the upload is happening
Previously it only reported progress after uploading each file.
2018-03-20 17:58:49 +01:00
Sybren A. Stüvel
56fb89da3d S3Packer now takes a URL as endpoint, not a hostname 2018-03-20 16:36:29 +01:00