{"id":18332084,"url":"https://github.com/sowrensen/fileculator","last_synced_at":"2026-05-07T01:05:22.858Z","repository":{"id":147630810,"uuid":"228588167","full_name":"sowrensen/fileculator","owner":"sowrensen","description":"Calculates total size of user uploaded files inside Laravel projects and writes output to public directory.","archived":false,"fork":false,"pushed_at":"2020-09-06T11:28:32.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-09T18:43:04.104Z","etag":null,"topics":["bash","filesize","filesystem","laravel","python","space","storage"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sowrensen.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-17T10:07:38.000Z","updated_at":"2020-09-06T11:28:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"64b0f0d4-44b3-421e-9961-3b2caafca2ab","html_url":"https://github.com/sowrensen/fileculator","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/sowrensen/fileculator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sowrensen%2Ffileculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sowrensen%2Ffileculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sowrensen%2Ffileculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sowrensen%2Ffileculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sowrensen","download_url":"https://codeload.github.com/sowrensen/fileculator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sowrensen%2Ffileculator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268334719,"owners_count":24233809,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","filesize","filesystem","laravel","python","space","storage"],"created_at":"2024-11-05T19:37:17.801Z","updated_at":"2026-05-07T01:05:22.827Z","avatar_url":"https://github.com/sowrensen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fileculator\n\nThis scripts calculates the total size of the `storage/app`\ndirectory (user uploaded files) of multiple **Laravel** apps. \nDefine the project `root` and `depth` in .env file and run \nthe script as a cron job.\n\nChangelog\n------\n\n#### Version 2.0.0\n\n - Added option to determine whole project size.\n - Improved code structure.\n - Added a `requirement.txt` file to work with usual virtualenv.\n - Removed Pipenv support.\n\n#### Version 1.0.1\n\n - Fixed bug related to project root.\n\n#### Version 1.0\n\n - Initial release\n\nUsage\n------\n\n### Setup\n\nRun following commands in your terminal to copy this repository and for primary setup.\n\n```\ngit clone https://github.com/sowrensen/fileculator.git\ncd fileculator\npython -m venv ./venv\n. venv/bin/activate\npip install -r requirements.txt\ncp .env.example .env\n```\n\n### Environment Variables\n\nBefore you can run the script, you've to declare a few environment variables \nin `.env` file. An example `.env` file has been added for your consistency. \nJust copy the `.env.example` file as `.env` and define the values for the \nfollowing two keys.\n\n - **PROJECT_ROOT**: This will be the directory where all of your Laravel \n  projects reside, e.g.` /home/\u003cuser\u003e/project`s, or `/var/www`, or \n  `/usr/share/nginx`. Note that, if you keep your projects into \n  some place which is in root directory, you have to run the \n  script as root. You know how Linux works, right?\n \n - **PROJECT_DEPTH** (1, 2): This key defines the searching depths for directories.\n The value should be either 1 or 2. If you have subdirectories in your root \n directory, you have to put 2, else put 1. For example, suppose this is the file\n structure inside your `PROJECT_ROOT`:\n \n   ```\n   App-1/\n    - App_1_Instance_1/\n    - App_1_Instance_2/\n   App-2/\n    - App_2_Instance_1/\n    - App_2_Instance_2/\n   ``` \n\n   In the above case, you have to put depth value 2. If there is only one\n   level of application directory, you can put 1.\n\n - **STORAGE_ONLY** (0, 1): This key defines the size of the whole Laravel project\n is to be calculate (including `vendor`, `node_modules` etc.) or only the storage\n directory. The expected value should be either 0 or 1. \n\nOutput\n------\n\nThe script calculates the total size (in bytes) of the `/storage/app` directory \ninside each Laravel project and puts the storage information into a json file \nnamed `storage.json` inside that directory which is Laravel's public directory. \nThus the generated file is ignored in any version control system. The data inside the \n`storage.json` file looks like:\n\n```\n{\n    \"size\": 112, \n    \"written_at\": \"2019-12-17 15:08:42.249758\"\n}\n```\n\nLaravel can use the information for various purposes. Since this is an expensive operation, \nyou should run the script as a cron job so that it doesn't interfere with HTTP response. \n_Note that, the output file will be replaced during the next run_.\n\nCron Example\n------------\n\nYou can run the file directly from cron job. However, if you face difficulties to run \npipenv from cron, better you create a bash script like this.\n\n```\n#!/bin/sh\n\nFILECULATOR=\"/path/to/fileculator\"\nPYTHON=\"${FILECULATOR}/venv/bin/python\"\nSCRIPT=\"${FILECULATOR}/fileculator.py\"\n\ncd \"${FILECULATOR}\" \u0026\u0026 \"${PYTHON}\" \"${SCRIPT}\"\n```\n\nMake the bash script executable by running:\n\n```shell\nchmod +x fileculator.sh\n```\n\nNow run the bash script as cron job. This following cron job will run on every even hour and write the log into the defined log file.\n```\n0 */2 * * * /path/to/bash/fileculator.sh \u003e /path/to/fileculator_output.log\n```\n\nIf you don't want a log file:\n```\n0 */2 * * * /path/to/bash/fileculator.sh \u003e/dev/null 2\u003e\u00261\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsowrensen%2Ffileculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsowrensen%2Ffileculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsowrensen%2Ffileculator/lists"}