|
3 | 3 | import argparse |
4 | 4 | import logging |
5 | 5 | import os |
| 6 | +import posixpath |
6 | 7 | import stat |
7 | 8 | import subprocess |
8 | 9 | import time |
|
16 | 17 | from ..cache import Cache |
17 | 18 | from ..constants import * # NOQA |
18 | 19 | from ..compress import CompressionSpec |
19 | | -from ..helpers import comment_validator, ChunkerParams, PathSpec |
| 20 | +from ..helpers import comment_validator, ChunkerParams, FilesystemPathSpec |
20 | 21 | from ..helpers import archivename_validator, FilesCacheMode |
21 | 22 | from ..helpers import eval_escapes |
22 | 23 | from ..helpers import timestamp, archive_ts_now |
23 | | -from ..helpers import get_cache_dir, os_stat, get_strip_prefix |
| 24 | +from ..helpers import get_cache_dir, os_stat, get_strip_prefix, slashify |
24 | 25 | from ..helpers import dir_is_tagged |
25 | 26 | from ..helpers import log_multi |
26 | 27 | from ..helpers import basic_json_data, json_print |
@@ -106,8 +107,9 @@ def create_inner(archive, cache, fso): |
106 | 107 | pipe_bin = sys.stdin.buffer |
107 | 108 | pipe = TextIOWrapper(pipe_bin, errors="surrogateescape") |
108 | 109 | for path in iter_separated(pipe, paths_sep): |
| 110 | + path = slashify(path) |
109 | 111 | strip_prefix = get_strip_prefix(path) |
110 | | - path = os.path.normpath(path) |
| 112 | + path = posixpath.normpath(path) |
111 | 113 | try: |
112 | 114 | with backup_io("stat"): |
113 | 115 | st = os_stat(path=path, parent_fd=None, name=None, follow_symlinks=False) |
@@ -160,7 +162,7 @@ def create_inner(archive, cache, fso): |
160 | 162 | continue |
161 | 163 |
|
162 | 164 | strip_prefix = get_strip_prefix(path) |
163 | | - path = os.path.normpath(path) |
| 165 | + path = posixpath.normpath(path) |
164 | 166 | try: |
165 | 167 | with backup_io("stat"): |
166 | 168 | st = os_stat(path=path, parent_fd=None, name=None, follow_symlinks=False) |
@@ -489,7 +491,7 @@ def _rec_walk( |
489 | 491 | path=path, fd=child_fd, st=st, strip_prefix=strip_prefix |
490 | 492 | ) |
491 | 493 | for tag_name in tag_names: |
492 | | - tag_path = os.path.join(path, tag_name) |
| 494 | + tag_path = posixpath.join(path, tag_name) |
493 | 495 | self._rec_walk( |
494 | 496 | path=tag_path, |
495 | 497 | parent_fd=child_fd, |
@@ -523,7 +525,7 @@ def _rec_walk( |
523 | 525 | with backup_io("scandir"): |
524 | 526 | entries = helpers.scandir_inorder(path=path, fd=child_fd) |
525 | 527 | for dirent in entries: |
526 | | - normpath = os.path.normpath(os.path.join(path, dirent.name)) |
| 528 | + normpath = posixpath.normpath(posixpath.join(path, dirent.name)) |
527 | 529 | self._rec_walk( |
528 | 530 | path=normpath, |
529 | 531 | parent_fd=child_fd, |
@@ -962,5 +964,5 @@ def build_parser_create(self, subparsers, common_parser, mid_common_parser): |
962 | 964 |
|
963 | 965 | subparser.add_argument("name", metavar="NAME", type=archivename_validator, help="specify the archive name") |
964 | 966 | subparser.add_argument( |
965 | | - "paths", metavar="PATH", nargs="*", type=PathSpec, action="extend", help="paths to archive" |
| 967 | + "paths", metavar="PATH", nargs="*", type=FilesystemPathSpec, action="extend", help="paths to archive" |
966 | 968 | ) |
0 commit comments