Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit c925b48

Browse files
committed
handle pagespeed off w/o file cache path set
fixes issues reported in ngx_pagespeed apache/incubator-pagespeed-ngx#956
1 parent 1fd007a commit c925b48

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

‎net/instaweb/system/system_cache_path.cc‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,23 @@ void SystemCachePath::ChildInit(SlowWorker* cache_clean_worker) {
205205
// Implementations must ensure the file cache path is an absolute path.
206206
// mod_pagespeed checks in mod_instaweb.cc:pagespeed_post_config while
207207
// ngx_pagespeed checks in ngx_pagespeed.cc:ps_merge_srv_conf.
208+
// There is at least one example where this check is violated in
209+
// ngx_pagespeed. Example:
210+
// server {
211+
// pagespeed off;
212+
// pagespeed FileCachePath "/tmp";
213+
// location / {
214+
// pagespeed on;
215+
// }
216+
// }
217+
//
218+
// Fixing this would require knowing if pagespeed is ever switched on within
219+
// a deeper level of the block. When this is parsed, we just have knowledge
220+
// of the higher-level server block.
208221
StringPiece path(options_->file_cache_path());
209-
DCHECK(path.starts_with("/"));
210222
cache_flush_filename = StrCat(
211-
path,
212-
path.ends_with("/") ? "" : "/",
223+
path, (path.size() > 0 &&
224+
path.ends_with("/")) ? "" : "/",
213225
cache_flush_filename);
214226
}
215227

0 commit comments

Comments
 (0)