1
0
mirror of https://github.com/php/php-src.git synced 2026-04-23 16:08:35 +02:00

- Clean up on flush

This commit is contained in:
Marcus Boerger
2007-01-27 23:02:42 +00:00
parent f86b7b96fc
commit 4b2eed1fc1
+18 -1
View File
@@ -1710,6 +1710,18 @@ static inline void phar_set_16(char *buffer, int var) /* {{{ */
#endif
} /* }}} */
static int phar_flush_clean_deleted_apply(void *data TSRMLS_DC) /* {{{ */
{
phar_entry_info *entry = (phar_entry_info *)data;
if (entry->fp_refcount <= 0 && entry->is_deleted) {
return ZEND_HASH_APPLY_REMOVE;
} else {
return ZEND_HASH_APPLY_KEEP;
}
}
/* }}} */
/**
* Save phar contents to disk
*
@@ -1805,7 +1817,12 @@ int phar_flush(phar_archive_data *archive, char *user_stub, long len TSRMLS_DC)
}
manifest_ftell = php_stream_tell(newfile);
halt_offset = manifest_ftell;
/* Check whether we can get rid of some of the deleted entries which are
* unused. However some might still be in use so even after this clean-up
* we need to skip entries marked is_deleted. */
zend_hash_apply(&archive->manifest, phar_flush_clean_deleted_apply TSRMLS_CC);
/* compress as necessary, calculate crcs, manifest size, and file sizes */
new_manifest_count = 0;
offset = 0;