We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum

Forum

Thread tagged as: Question

Clearing unused assets

I'm going to embarrass myself here, I'm sure, but how do I clear unused assets from a server? When a user deletes from a website via the CMS they don't get cleared from the server (or do they…?) so the server fills up.

Is there an easy way to clear the unused assets? Or if there isn't what would you recommend I do to clear unused assets from the server? Is there a database table I can sift through to see what's active and manually delete the assets that aren't referenced? Or is there a more efficient way?

Thanks :)

Martin Underhill

Martin Underhill 5 points

  • 2 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

They get deleted once they've fallen out of the undo history.

Disk space is super cheap though. If you're hitting against limits, it'd be a good idea to increase the space.

Ah, do they get deleted from the server too? I thought it was just from the CMS. That's good :)

Yeah, the client's a primary school so they have some pretty tight restrictions on hosting and the hosting company is a bit old school in their allowances and prices :(

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, they get deleted from the server. It can take a while - I think the default history stack is set at 8.

Great stuff :) Thanks!

Looks like when the content is deleted from a region or item the asset is sticking around in the Assets pane. Is there any way to get rid of the asset from there? An option to have it clear from Assets automatically would be cool, but I'm guessing it's a manual process. I can do it as I'm the primary admin but my client can't as only the primary admin can delete assets, can't they? Or am I off on one of my misunderstandings again…? :D

Drew McLellan

Drew McLellan 2638 points
Perch Support

As mentioned, it'll stay until it falls out of the undo history.

Ah of course. Unused assets drop off unless they're marked as Library Assets. Gotcha.

So it looks like my assets are clearing ok. But the item in the Assets is still there, just with a broken image reference. Here's a screenshot: https://www.dropbox.com/s/6l0fr6edybcc480/Screen%20Shot%202016-12-01%20at%2011.43.02%20am.png?dl=0

Should these clear too, or should I jump in and delete them manually?

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, that should all go at the same time.

Oh… Here are the diagnostics – let me know if the extended report is more useful.

Perch: 2.8.32, PHP: 5.4.45, MySQL: 5.5.53, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.32), assets (2.8.32), categories (2.8.32), perch_blog (5.0), perch_events (1.9.2), perch_gallery (2.8.6), perch_backup (1.2)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_blog', 'perch_gallery', 'perch_events', ); ?>
PERCH_LOGINPATH: /cms
PERCH_PATH: /var/www/vhosts/skeltonnewbyhall.n-yorks.sch.uk/httpdocs/cms
PERCH_CORE: /var/www/vhosts/skeltonnewbyhall.n-yorks.sch.uk/httpdocs/cms/core
PERCH_RESFILEPATH: /var/www/vhosts/skeltonnewbyhall.n-yorks.sch.uk/httpdocs/cms/resources
Image manipulation: GD
PHP limits: Max upload 128M, Max POST 8M, Memory: 128M, Total max file upload: 8M
F1: 2edba60ed1f613d6dd804feb202456a2
Resource folder writeable: Yes
SCRIPT_NAME: /cms/core/settings/diagnostics/index.php
REQUEST_URI: /cms/core/settings/diagnostics/
DOCUMENT_ROOT: /var/www/vhosts/skeltonnewbyhall.n-yorks.sch.uk/httpdocs
HTTP_HOST: skeltonnewbyhall.n-yorks.sch.uk
Drew McLellan

Drew McLellan 2638 points
Perch Support

What's the state of it currently? What point are you trying to get to?

The Assets section of the website is full of those asset items with broken image references since the images have been removed but not the reference to them. So I'd like to have the assets clear completely – from the disk and from Perch, leaving the assets section nice and tidy. I'd prefer not to have to do it manually as there are hundreds :D

Drew McLellan

Drew McLellan 2638 points
Perch Support

Did they all go at once? Are the files missing from disk? What happened?

My client got a message from their hosting provider that they were reaching 'full' on disk space so I presented them with some options. They chose to remove old galleries to clear up space rather than upgrade the hosting. So they went through and removed loads of old albums from their site through the Gallery app.

The files have been cleared from the disk ok but the item in the Assets section of the CMS is still there. So I'm seeing the item in Assets with the browser's broken image symbol, as the asset itself isn't on the server anymore: https://www.dropbox.com/s/6l0fr6edybcc480/Screen%20Shot%202016-12-01%20at%2011.43.02%20am.png?dl=0

Drew McLellan

Drew McLellan 2638 points
Perch Support

They deleted them from the Gallery app, but they were still showing in Assets?

That sounds like a weird edge case with the bolting on of the Assets stuff into the old Gallery app.

That's right – the were deleted from the Gallery app and didn't clear from the Assets, even though the image files were removed ok. Is this something I should wait for a patch for or should I start clearing the empty asset items from Perch manually?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Start clearing them manually. The Gallery app is more likely to be deprecated than patched.

Right you are – I guessed as much as I can do everything the Gallery app does with Perch core these days. It struck me a while back that Events is in the same boat. ♥︎Perch♥︎ :D