• Welcome to the Chevereto User Community!

    Here, users from all over the world come together to learn, share, and collaborate on everything related to Chevereto. It's a place to exchange ideas, ask questions, and help improve the software.

    Please keep in mind:

    • This community is user-driven. Always be polite and respectful to others.
    • Support development by purchasing a Chevereto license, which also gives you priority support.
    • Go further by joining the Community Subscription for even faster response times and to help sustain this space
  • Chevereto Support CLST

    Support response

    Support checklist

    • Got a Something went wrong message? Read this guide and provide the actual error. Do not skip this.
    • Confirm that the server meets the System Requirements
    • Check for any available Hotfix - your issue could be already reported/fixed
    • Read documentation - It will be required to Debug and understand Errors for a faster support response

How to recount image storage space used of each storage id in database

lovedigit

👽 Chevereto Freak
Hello,

I had to move an external storage (Say A) files to the Other storage container (Say B). I transferred all images from A to B. Additionally, I wanted to merge the storage A and B in the database, So I replaced the "image_storage_id" in database from 5 (Storage id of A) to 4 (Storage id of B) and than deleted the storage id 5 from "xxx_storages".

Everything went smooth, and I could never imagine that it would be so easy. Now, I understand why @Rodolfo choose storage id to map images instead of url. Fantastic.

Everything looks clean and less cluttered and I can add more external storage without having to add multiple subdomain pointing to the same Storage container.

However, I need a little help updating the "Size of Storage used by each Storage id". I know it doesn't really matter since the total value of the actual storage used is still the same, but it would still be helpful if I ever had to monitor the available space on the container. Otherwise, I would have to check it regularly on the storage container.

Help would be much appreciated.
 
I think I broke something. I don't understand the structure of the database tables. Is there somewhere else I need to change the storage ID? New images are not being stored on external storage. They are being uploaded to the local storage.

Edit: Nevermind. Fixed it. Had to disable and enable the storage. Still need help with the used space though. Thanks.
 
Last edited:
Hi @lovedigit

Check app/install/installer.php it has a very neat examples of massive counts + update statements. Basically you need to SELECT SUM all the image size fields then update the old value.
 
Can you point out an example? I tried tirelessly, but couldn't figure out what I am searching for in app/install/installer.php
 
Just select sum all the images matching the storage id (image_size, image_tumb_size, image_medium_size) and then update the storage usage value.
 
Code:
UPDATE chv_storages SET storage_space_used = (SELECT (SUM(image_size)+SUM(image_thumb_size)+SUM(image_medium_size)) disk FROM chv_images WHERE image_storage_id = X) WHERE storage_id = X;

X = Storage ID.
 
Code:
UPDATE chv_storages SET storage_space_used = (SELECT (SUM(image_size)+SUM(image_thumb_size)+SUM(image_medium_size)) disk FROM chv_images WHERE image_storage_id = X) WHERE storage_id = X;

X = Storage ID.

Thank you! very much for this. <3🙂
 
Back
Top