Skip to content

Commit

Permalink
Remove debugging print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdutton committed Oct 6, 2020
1 parent 1b06f92 commit b9280c6
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 13 deletions.
9 changes: 0 additions & 9 deletions invenio_files_rest/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,27 +811,23 @@ def verify_checksum(self, progress_callback=None, chunk_size=None,
@ensure_writable()
def initialize(self, preferred_location: Location, size=0, **kwargs):
"""Initialize file."""
print("WRI1", self.writable)
if hasattr(current_files_rest.storage_factory, 'initialize'):
# New behaviour, with a new-style storage factory
result = current_files_rest.storage_factory.initialize(
fileinstance=self,
preferred_location=preferred_location,
size=size,
)
print("WRI2", self.writable)
else:
# Old behaviour, with an old-style storage factory
storage = self.storage(default_location=preferred_location.uri, **kwargs)
result = storage.initialize(size=size)
print("WRI3", self.writable, storage)
self.update_file_metadata(
result,
readable=False,
writable=True,
storage_backend=type(storage).backend_name if isinstance(storage, StorageBackend) else None,
)
print("WRI4", self.writable, result)

@ensure_writable()
def init_contents(self, size=0, default_location: str=None, **kwargs):
Expand Down Expand Up @@ -936,7 +932,6 @@ def update_file_metadata(self, file_metadata: Union[Tuple,Dict] = None, **kwargs
file_metadata += (kwargs.get('writable', False),)
if len(file_metadata) < 6:
file_metadata += (kwargs.get('storage_class', None),)
print(file_metadata)
self.set_uri(*file_metadata)
elif isinstance(file_metadata, dict):
file_metadata.update(kwargs)
Expand Down Expand Up @@ -1622,7 +1617,6 @@ def create(cls, bucket, key, size, chunk_size):

with db.session.begin_nested():
file_ = FileInstance.create()
print("WR2", file_.writable)
file_.size = size
obj = cls(
upload_id=uuid.uuid4(),
Expand All @@ -1635,13 +1629,11 @@ def create(cls, bucket, key, size, chunk_size):
)
bucket.size += size
db.session.add(obj)
print("WR3", file_.writable)
file_.init_contents(
size=size,
default_location=bucket.location.uri,
default_storage_class=bucket.default_storage_class,
)
print("WR4", file_.writable)
return obj

@classmethod
Expand Down Expand Up @@ -1782,7 +1774,6 @@ def set_contents(self, stream, progress_callback=None):
:param chunk_size: Desired chunk size to read stream in. It is up to
the storage interface if it respects this value.
"""
print("writable", self.multipart.file.writable)
size, checksum = self.multipart.file.update_contents(
stream, seek=self.start_byte, size=self.part_size,
progress_callback=progress_callback,
Expand Down
1 change: 0 additions & 1 deletion tests/test_models_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def test_part_creation(app, db, bucket, get_md5):
mp = MultipartObject.create(bucket, 'test.txt', 5, 2)
db.session.commit()
assert bucket.size == 5
print("WR", mp.file.writable)
Part.create(mp, 2, stream=BytesIO(b'p'))
Part.create(mp, 0, stream=BytesIO(b'p1'))
Part.create(mp, 1, stream=BytesIO(b'p2'))
Expand Down
3 changes: 0 additions & 3 deletions tests/test_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,8 @@ def test_pyfs_save_limits(pyfs):
def test_pyfs_update(pyfs, pyfs_testpath, get_md5):
"""Test update of file."""
pyfs.initialize(size=100)
print("E1", pyfs.open().read()[:6])
pyfs.update(BytesIO(b'cd'), seek=2, size=2)
print("E2", pyfs.open().read()[:6])
pyfs.update(BytesIO(b'ab'), seek=0, size=2)
print("E3", pyfs.open().read()[:6])

with open(pyfs_testpath) as fp:
content = fp.read()
Expand Down

0 comments on commit b9280c6

Please sign in to comment.