Skip to content

Commit

Permalink
Edits
Browse files Browse the repository at this point in the history
  • Loading branch information
forsyth2 committed Apr 13, 2023
1 parent 0025e13 commit 8e9a4fa
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions zstash/hpss_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from __future__ import absolute_import, print_function

import hashlib
import os
import os.path
import shutil
import sqlite3
import tarfile
import traceback
Expand Down Expand Up @@ -176,6 +178,16 @@ def add_file(

# FIXME: error: "TarFile" has no attribute "offset"
offset: int = tar.offset # type: ignore
print(f"file_name={file_name}")
print(f"is_link={os.path.islink(file_name)}")
if os.path.islink(file_name):
linked_file_name = os.path.realpath(file_name)
print(f"realpath file_name={linked_file_name}")
print(f"cwd={os.getcwd()}")
print(f"ls={os.listdir()}")
os.remove(file_name) # Remove symbolic link and create a hard copy
shutil.copy(linked_file_name, file_name)
print(os.listdir())
tarinfo: tarfile.TarInfo = tar.gettarinfo(file_name)
# Change the size of any hardlinks from 0 to the size of the actual file
if tarinfo.islnk():
Expand All @@ -186,11 +198,7 @@ def add_file(
md5: Optional[str] = None
# Only add files or hardlinks.
# (So don't add directories).
if tarinfo.isfile() or tarinfo.islnk() or tarinfo.issym():
# TODO: test with tutorial demo dir
# /global/homes/f/forsyth/zstash_test/n247
if tarinfo.issym():
file_name = os.path.realpath(file_name)
if tarinfo.isfile() or tarinfo.islnk():
f: _io.TextIOWrapper = open(file_name, "rb")
hash_md5: _hashlib.HASH = hashlib.md5()
if tar.fileobj is not None:
Expand Down

0 comments on commit 8e9a4fa

Please sign in to comment.