@@ -39,9 +39,10 @@ public function upload_files( string $processed_site_path ) : void {
3939 )
4040 );
4141
42+ $ object_acl = Controller::getValue ( 's3ObjectACL ' );
4243 $ put_data = [
4344 'Bucket ' => Controller::getValue ( 's3Bucket ' ),
44- 'ACL ' => ' public-read ' ,
45+ 'ACL ' => $ object_acl === '' ? ' public-read ' : $ object_acl ,
4546 ];
4647
4748 $ cache_control = Controller::getValue ( 's3CacheControl ' );
@@ -64,10 +65,6 @@ public function upload_files( string $processed_site_path ) : void {
6465
6566 $ cache_key = str_replace ( $ processed_site_path , '' , $ filename );
6667
67- if ( \WP2Static \DeployCache::fileisCached ( $ cache_key , $ namespace ) ) {
68- continue ;
69- }
70-
7168 if ( ! $ real_filepath ) {
7269 $ err = 'Trying to deploy unknown file to S3: ' . $ filename ;
7370 \WP2Static \WsLog::l ( $ err );
@@ -93,13 +90,26 @@ public function upload_files( string $processed_site_path ) : void {
9390 }
9491
9592 $ put_data ['Key ' ] = $ s3_key ;
96- $ put_data ['Body ' ] = file_get_contents ( $ filename );
9793 $ put_data ['ContentType ' ] = $ mime_type ;
94+ $ put_data_hash = md5 ( json_encode ( $ put_data ) );
95+ $ put_data ['Body ' ] = file_get_contents ( $ filename );
96+ $ body_hash = md5 ( $ put_data ['Body ' ] );
97+ $ hash = md5 ( $ put_data_hash . $ body_hash );
98+
99+ $ is_cached = \WP2Static \DeployCache::fileisCached (
100+ $ cache_key ,
101+ $ namespace ,
102+ $ hash ,
103+ );
104+
105+ if ( $ is_cached ) {
106+ continue ;
107+ }
98108
99109 $ result = $ s3 ->putObject ( $ put_data );
100110
101111 if ( $ result ['@metadata ' ]['statusCode ' ] === 200 ) {
102- \WP2Static \DeployCache::addFile ( $ cache_key , $ namespace );
112+ \WP2Static \DeployCache::addFile ( $ cache_key , $ namespace, $ hash );
103113
104114 if ( $ cf_max_paths >= count ( $ cf_stale_paths ) ) {
105115 $ cf_key = $ cache_key ;
@@ -118,23 +128,12 @@ public function upload_files( string $processed_site_path ) : void {
118128 $ redirects = apply_filters ( 'wp2static_list_redirects ' , [] );
119129
120130 foreach ( $ redirects as $ redirect ) {
121- $ file_hash = md5 ( '301 ' . $ redirect ['redirect_to ' ] );
122131 $ cache_key = $ redirect ['url ' ];
123132
124133 if ( mb_substr ( $ cache_key , -1 ) === '/ ' ) {
125134 $ cache_key = $ cache_key . 'index.html ' ;
126135 }
127136
128- $ is_cached = \WP2Static \DeployCache::fileisCached (
129- $ cache_key ,
130- $ namespace ,
131- $ file_hash
132- );
133-
134- if ( $ is_cached ) {
135- continue ;
136- }
137-
138137 $ s3_key =
139138 Controller::getValue ( 's3RemotePath ' ) ?
140139 Controller::getValue ( 's3RemotePath ' ) . '/ ' .
@@ -143,11 +142,22 @@ public function upload_files( string $processed_site_path ) : void {
143142
144143 $ put_data ['Key ' ] = $ s3_key ;
145144 $ put_data ['WebsiteRedirectLocation ' ] = $ redirect ['redirect_to ' ];
145+ $ hash = md5 ( json_encode ( $ put_data ) );
146+
147+ $ is_cached = \WP2Static \DeployCache::fileisCached (
148+ $ cache_key ,
149+ $ namespace ,
150+ $ hash ,
151+ );
152+
153+ if ( $ is_cached ) {
154+ continue ;
155+ }
146156
147157 $ result = $ s3 ->putObject ( $ put_data );
148158
149159 if ( $ result ['@metadata ' ]['statusCode ' ] === 200 ) {
150- \WP2Static \DeployCache::addFile ( $ cache_key , $ namespace , $ file_hash );
160+ \WP2Static \DeployCache::addFile ( $ cache_key , $ namespace , $ hash );
151161
152162 if ( $ cf_max_paths >= count ( $ cf_stale_paths ) ) {
153163 $ cf_key = $ cache_key ;
0 commit comments