Skip to content

Commit 23f48f2

Browse files
committed
Replace fileIsCached use with PathInfo cache data
Use the new data attached to PathInfo by DeployCache::addCacheData. This lets us delete DeployCache::fileIsCached.
1 parent d288c0c commit 23f48f2

3 files changed

Lines changed: 4 additions & 35 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
- Rename file_hash to data_hash to reflect that it
3535
can include metadata.
3636
- Add deployed_at column and an index on it.
37+
- Batch queries to the deployed_files table for better
38+
performance.
3739

3840
## 9.3.2 (2025-07-29)
3941

src/DeployCache.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -137,34 +137,6 @@ public static function addFile(
137137
$wpdb->query( $sql );
138138
}
139139

140-
/**
141-
* Checks if file can skip deployment
142-
* - uses hash of file and path's hash
143-
*/
144-
public static function fileisCached(
145-
string $path,
146-
string $ns = self::DEFAULT_NAMESPACE,
147-
string $data_hash,
148-
): bool {
149-
global $wpdb;
150-
151-
$path_hash = md5( $path );
152-
153-
$table_name = self::getTableName();
154-
155-
$sql = $wpdb->prepare(
156-
"SELECT path_hash FROM $table_name WHERE" .
157-
' path_hash = %s AND data_hash = %s AND namespace = %s LIMIT 1',
158-
$path_hash,
159-
$data_hash,
160-
$ns
161-
);
162-
163-
$hash = $wpdb->get_var( $sql );
164-
165-
return (bool) $hash;
166-
}
167-
168140
public static function truncate(
169141
string $ns = ''
170142
): void {

src/S3/Deployer.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,8 @@ public function uploadFilesIter( \Iterator $path_infos ): void {
194194
}
195195
}
196196

197-
$is_cached = DeployCache::fileisCached(
198-
$cache_key,
199-
self::DEFAULT_NAMESPACE,
200-
$hash,
201-
);
202-
203-
if ( $is_cached ) {
197+
if ( isset( $path_info->deploy_cache )
198+
&& ( $path_info->deploy_cache[ self::DEFAULT_NAMESPACE ] ?? null ) === $hash ) {
204199
++$this->deploy_cache_ct;
205200
if ( STATIC_DEPLOY_DEBUG ) {
206201
WsLog::d( 'Skipping deploy of cached file ' . $cache_key );

0 commit comments

Comments
 (0)