This patch provides an implementation of hook_cron() which scans the ups_labels directory and removes any label images that are older than an admin-configurable time. Also adds the admin menu for selecting amount of time to keep labels on disk. Also, and unrelated, adds a fieldset to the uc_ups_fulfill_order() form to pretty-fy it and to make it consistent with the manual shipping form.

CommentFileSizeAuthor
uc_ups.admin_.inc_.patch942 bytestr
uc_ups.module.patch2.31 KBtr

Comments

Island Usurper’s picture

Status: Needs review » Needs work

OK, that's a good idea, but I'd like to see a couple of changes. I can imagine that someone might want to keep their label images around for archives or something, so an option to not delete them periodically would be good. I would just add array(0 => t('Never')) to the options.

Secondly, it makes me a little nervous to delete all of the files in the ups_labels folder. If that setting gets changed to just the files folder, you'd have a serious problem when the next cron run rolls around. I would check that the file name starts with "labelZ" and ends with ".gif" before deleting it.

Finally, "3 days 12 hours" sounds like an awkward amount of time to keep something. 3 or 5 days is probably better.

tr’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Needs work » Active

Committed these changes to 6.x-2.x and 7.x-3.x. Added code to make sure we're only deleting labels, nothing else that might happen to be in that folder. Did not yet add the "Never" feature. Leaving this open for that purpose.

tr’s picture

Status: Active » Fixed

Committed "never" feature to both branches. "Never" is the default for uc_ups, so no deletion will happen unless the admin explicitly turns this on.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.