Skip to content
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

Add documentation on how to free disk space #648

Open
1 task done
lucamanga opened this issue Nov 9, 2023 · 9 comments
Open
1 task done

Add documentation on how to free disk space #648

lucamanga opened this issue Nov 9, 2023 · 9 comments
Assignees
Labels
feature New feature or request

Comments

@lucamanga
Copy link

lucamanga commented Nov 9, 2023

Checklist

  • I've searched through the current issues to make sure this feature hasn't been requested already.

Motivation

I noticed that, over time, G3WSuite creates many temporary files.
Here are some "big" folders I found:

  1. In /tmp there are many files like this (I'm using the docker version)
   QGIS3-xxxxx  (as folder)
   QGIS3.xxxxx  (as file)
  1. in .../media/temp_upload I have 3.221 qgs/qgz files, for a total directory size of 3.3GB

Suggested solution

In the documentation, suggest a script to clean files (to run via crontab on night)

Alternatives considered

No response

@lucamanga lucamanga added the feature New feature or request label Nov 9, 2023
@Raruto
Copy link
Contributor

Raruto commented Nov 13, 2023

Hi @lucamanga,

since you have already explored the topic (or at least you have an initial idea), would you like to give us a hand on this?

To achieve that I would recommend start exploring some of built in Django management commands: 👇

python3 manage.py
Type 'manage.py help <subcommand>' for help on a specific subcommand.

Available subcommands:

[auth]
    changepassword
    createsuperuser

[authtoken]
    drf_create_token

[base]
    export_language_files
    generate_secret_key_file
    import_language_files
    initadmin
    set_passwords
    update_modules

[contenttypes]
    remove_stale_contenttypes

[core]
    clear_db_logs

[django]
    check
    compilemessages
    createcachetable
    dbshell
    diffsettings
    dumpdata
    flush
    makemessages
    makemigrations
    migrate
    sendtestemail
    shell
    showmigrations
    sqlflush
    sqlmigrate
    sqlsequencereset
    squashmigrations
    startapp
    startproject
    test
    testserver

[django_extensions]
    admin_generator
    clean_pyc
    clear_cache
    compile_pyc
    create_command
    create_jobs
    create_template_tags
    delete_squashed_migrations
    describe_form
    drop_test_database
    dumpscript
    export_emails
    find_template
    generate_password
    generate_secret_key
    graph_models
    list_model_info
    list_signals
    mail_debug
    merge_model_instances
    notes
    pipchecker
    print_settings
    print_user_for_session
    reset_db
    reset_schema
    runjob
    runjobs
    runprofileserver
    runscript
    runserver_plus
    set_default_site
    set_fake_emails
    set_fake_passwords
    shell_plus
    show_template_tags
    show_urls
    sqlcreate
    sqldiff
    sqldsn
    sync_s3
    syncdata
    unreferenced_files
    update_permissions
    validate_templates

[django_file_form]
    delete_unused_files

[djhuey]
    run_huey

[drf_spectacular]
    spectacular

[editing]
    check_features_locked
    migration_grant_to_atomic_permissions

[gis]
    inspectdb
    ogrinspect

[guardian]
    clean_orphan_obj_perms

[modeltranslation]
    loaddata
    sync_translation_fields
    update_translation_fields

[portal]
    loaddata_picture

[rest_framework]
    generateschema

[sessions]
    clearsessions

[sitetree]
    sitetree_resync_apps
    sitetreedump
    sitetreeload

[staticfiles]
    collectstatic
    findstatic
    runserver

[usersmanage]
    load_demo_dev_users_groups

If you don't find the right one, please also try with writing a custom one to propose to the rest of us.

Thanks in advance

👋 Raruto

@lucamanga
Copy link
Author

Ok, when I have time I'll see! Thank you for the hint

@Raruto
Copy link
Contributor

Raruto commented Nov 16, 2023

  1. in .../media/temp_upload I have 3.221 qgs/qgz files, for a total directory size of 3.3GB

@wlorenzetti I also found many orphaned files in here: media/projects/*.qgs

I think because currently these are not removed when deleting a project/group (or when updating/uploading a previously loaded .qgs file through the admin dashboard).

@wlorenzetti
Copy link
Member

@Raruto I just make some tests, I try to create upload end delete the project inside G3W-ADMIN, but I don't have any orphans, also change the filename of the uploading .qgs file..
As say @lucamanga the media/temp_upload can be contains orphaned files, i.e. if you try to upload a project and before to save it upload again another .qgs file, in this case the first project uploaded becomes a orphan.

@lucamanga
Copy link
Author

@wlorenzetti so? Can I delete all files in that folder?

@wlorenzetti
Copy link
Member

@wlorenzetti so? Can I delete all files in that folder?

I think if you create cron than delete it every night it could be useful.

@wlorenzetti
Copy link
Member

@wlorenzetti so? Can I delete all files in that folder?

For safety, I suggest to you the django command delete_unused_files, it is a custom command of module django_file_form that clear the temp directory from unused file. https://mbraak.github.io/django-file-form/usage/#usage

@Raruto
Copy link
Contributor

Raruto commented Nov 16, 2023

@Raruto I just make some tests, I try to create upload end delete the project inside G3W-ADMIN, but I don't have any orphans, also change the filename of the uploading .qgs file..

Here's how I reproduce it on 3.7-dev (docker install with DEBUG: true):

Before

image

image

image

After

image

image

image


  1. in .../media/temp_upload I have 3.221 qgs/qgz files, for a total directory size of 3.3GB

Can I delete all files in that folder?

I think if you create cron than delete it every night it could be useful.

@wlorenzetti @lucamanga docker users can also consider edit their entrypoint file accordingly to have it deleted every time the container is restarted: https://github.com/g3w-suite/g3w-suite-docker/blob/f90ce492fcb962969c0eb1b5d21611dadd36025b/scripts/

python3 /code/g3w-admin/manage.py delete_unused_files

image

@wlorenzetti
Copy link
Member

wlorenzetti commented Nov 16, 2023

Here's how I reproduce it on 3.7-dev (docker install with DEBUG: true):
...

Ok, when uploading the project with project title updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants