mirror of
https://github.com/pirate/ArchiveBox.git
synced 2025-08-23 22:53:00 +02:00
fix uuid checks on save
This commit is contained in:
@@ -93,6 +93,7 @@ class ABIDModel(models.Model):
|
|||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
assert str(self.id) == str(self.ABID.uuid), f'self.id {self.id} does not match self.ABID {self.ABID.uuid}'
|
assert str(self.id) == str(self.ABID.uuid), f'self.id {self.id} does not match self.ABID {self.ABID.uuid}'
|
||||||
assert str(self.abid) == str(self.ABID), f'self.abid {self.id} does not match self.ABID {self.ABID.uuid}'
|
assert str(self.abid) == str(self.ABID), f'self.abid {self.id} does not match self.ABID {self.ABID.uuid}'
|
||||||
|
assert str(self.uuid) == str(self.ABID.uuid), f'self.uuid ({self.uuid}) does not match .ABID.uuid ({self.ABID.uuid})'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def abid_values(self) -> Dict[str, Any]:
|
def abid_values(self) -> Dict[str, Any]:
|
||||||
@@ -186,6 +187,14 @@ class ABIDModel(models.Model):
|
|||||||
Get a uuid.UUID (v4) representation of the object's ABID.
|
Get a uuid.UUID (v4) representation of the object's ABID.
|
||||||
"""
|
"""
|
||||||
return self.ABID.uuid
|
return self.ABID.uuid
|
||||||
|
|
||||||
|
@property
|
||||||
|
def uuid(self) -> str:
|
||||||
|
"""
|
||||||
|
Get a str uuid.UUID (v4) representation of the object's ABID.
|
||||||
|
"""
|
||||||
|
assert str(self.id) == str(self.ABID.uuid)
|
||||||
|
return str(self.id)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def TypeID(self) -> TypeID:
|
def TypeID(self) -> TypeID:
|
||||||
|
@@ -91,4 +91,5 @@ class SinglefileConfig(AppConfig):
|
|||||||
verbose_name = 'SingleFile'
|
verbose_name = 'SingleFile'
|
||||||
|
|
||||||
def ready(self):
|
def ready(self):
|
||||||
print('Loaded singlefile plugin')
|
pass
|
||||||
|
# print('Loaded singlefile plugin')
|
||||||
|
@@ -158,9 +158,6 @@ class Snapshot(ABIDModel):
|
|||||||
|
|
||||||
objects = SnapshotManager()
|
objects = SnapshotManager()
|
||||||
|
|
||||||
@property
|
|
||||||
def uuid(self):
|
|
||||||
return self.id
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
title = (self.title_stripped or '-')[:64]
|
title = (self.title_stripped or '-')[:64]
|
||||||
@@ -170,13 +167,6 @@ class Snapshot(ABIDModel):
|
|||||||
title = (self.title_stripped or '-')[:64]
|
title = (self.title_stripped or '-')[:64]
|
||||||
return f'[{self.timestamp}] {self.url[:64]} ({title})'
|
return f'[{self.timestamp}] {self.url[:64]} ({title})'
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
|
||||||
super().save(*args, **kwargs)
|
|
||||||
try:
|
|
||||||
assert str(self.id) == str(self.ABID.uuid) == str(self.uuid), f'Snapshot.id ({self.id}) does not match .ABID.uuid ({self.ABID.uuid})'
|
|
||||||
except AssertionError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_json(cls, info: dict):
|
def from_json(cls, info: dict):
|
||||||
info = {k: v for k, v in info.items() if k in cls.keys}
|
info = {k: v for k, v in info.items() if k in cls.keys}
|
||||||
@@ -471,17 +461,6 @@ class ArchiveResult(ABIDModel):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.extractor
|
return self.extractor
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
|
||||||
super().save(*args, **kwargs)
|
|
||||||
try:
|
|
||||||
assert str(self.id) == str(self.ABID.uuid) == str(self.uuid), f'ArchiveResult.id ({self.id}) does not match .ABID.uuid ({self.ABID.uuid})'
|
|
||||||
except AssertionError as e:
|
|
||||||
print(e)
|
|
||||||
|
|
||||||
@property
|
|
||||||
def uuid(self):
|
|
||||||
return self.id
|
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def snapshot_dir(self):
|
def snapshot_dir(self):
|
||||||
return Path(self.snapshot.link_dir)
|
return Path(self.snapshot.link_dir)
|
||||||
|
Reference in New Issue
Block a user