-
-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce filestorage
app, support for multiple file backends and store file metadata in the database
#1104
base: master
Are you sure you want to change the base?
Conversation
Task linked: QF-2760 Keep the file metadata in the database |
895f958
to
59dba4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First review focused on docker compose
and environment / migrations considerations, trying to set it up on my local.
Did not have a look at the python code that much yet.
59dba4d
to
a31eaa0
Compare
@gounux apologies for the force push, I first rebased and then realized I had to force push. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2nd review round, diving deeper into it.
Mainly curiosity, sometimes naive questions to understand better.
3rd one will come soon
docker-app/qfieldcloud/core/migrations/0080_file_storage_project_and_more.py
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3rd review round.
I faced an error when creating a project with the basic OSM .qgs
file :
- project exists in the database
- in the database, the project has
file_storage
value todefault
, but the files are stored in the legacybucket
- running the
migrateprojectstorage
command throw this error :Exception: Cannot migrate to storage "default", project is already stored there!
After looking at the Jobs
in QFC Admin, the Process QGIS Project File
have Failed
status with UNKNOWN
Error type :
The Output pre
display the error Local files list for project "UUID": empty!
:
Feedback pre
shows a ProjectFileNotFoundException
thrown :
def next_version(self) -> "FileVersion | None": | ||
file_version_qs = FileVersion.objects.filter( | ||
file=self.file, | ||
uploaded_at__lt=self.uploaded_at, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uploaded_at__lt=self.uploaded_at, | |
uploaded_at__gt=self.uploaded_at, |
md5sum = serializers.SerializerMethodField() | ||
sha256 = serializers.SerializerMethodField() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need those ?
name="is_locked", | ||
field=models.BooleanField( | ||
default=False, | ||
help_text="If set to true, the project is temporarily locked. Locking is internal QFieldCloud mechansism related to file storage migration or other file operations.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help_text="If set to true, the project is temporarily locked. Locking is internal QFieldCloud mechansism related to file storage migration or other file operations.", | |
help_text="If set to true, the project is temporarily locked. Locking is internal QFieldCloud mechanism related to file storage migration or other file operations.", |
is_locked = models.BooleanField( | ||
_("Is locked"), | ||
help_text=_( | ||
"If set to true, the project is temporarily locked. Locking is internal QFieldCloud mechansism related to file storage migration or other file operations." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"If set to true, the project is temporarily locked. Locking is internal QFieldCloud mechansism related to file storage migration or other file operations." | |
"If set to true, the project is temporarily locked. Locking is internal QFieldCloud mechanism related to file storage migration or other file operations." |
def whatever(self): | ||
qs = self.annotate( | ||
last_version_pk=( | ||
FileVersion.objects.filter(file=OuterRef("pk")) | ||
.order_by("-uploaded_at") | ||
.values("pk")[:1] | ||
) | ||
) | ||
qs = qs.prefetch_related("versions") | ||
return qs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this strictly mandatory or did you use this for testing ?
# the s3 storage has 1024 bytes (not chars!) limit: https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html | ||
max_length=1024, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then why use 1024 characters and not the STORAGE_FILENAME_MAX_CHAR_LENGTH
settings variable ?
last_job = project.last_package_job | ||
if last_job.feedback.get("feedback_version") == "2.0": | ||
layers = last_job.feedback["outputs"]["qgis_layers_data"]["layers_by_id"] | ||
else: | ||
steps = last_job.feedback.get("steps", []) | ||
layers = ( | ||
steps[1]["outputs"]["layer_checks"] | ||
if len(steps) > 2 and steps[1].get("stage", 1) == 2 | ||
else None | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Find it hard to understand what this is supposed to be doing.
Would a comment be welcome ?
This PR introduces a new enhanced way to store filedata. Before just dumped everything to the Object Storage. This made everything clumsy, slow and not flexible.
The plan is to quickly migrate all projects to the new storage and delete the legacy approach.
I have closed #1065, which was the same PR.