2424
2525namespace OC \Template ;
2626
27+ use OCP \AppFramework \Utility \ITimeFactory ;
2728use OCP \Files \IAppData ;
2829use OCP \Files \NotFoundException ;
2930use OCP \Files \SimpleFS \ISimpleFolder ;
@@ -46,6 +47,9 @@ class IconsCacher {
4647 /** @var IURLGenerator */
4748 protected $ urlGenerator ;
4849
50+ /** @var ITimeFactory */
51+ protected $ timeFactory ;
52+
4953 /** @var string */
5054 private $ iconVarRE = '/--(icon-[a-zA-Z0-9-]+):\s?url\([" \']([a-zA-Z0-9-_\~\/\.\?\=]+)[^;]+;/m ' ;
5155
@@ -56,13 +60,17 @@ class IconsCacher {
5660 * @param ILogger $logger
5761 * @param Factory $appDataFactory
5862 * @param IURLGenerator $urlGenerator
63+ * @param ITimeFactory $timeFactory
64+ * @throws \OCP\Files\NotPermittedException
5965 */
6066 public function __construct (ILogger $ logger ,
6167 Factory $ appDataFactory ,
62- IURLGenerator $ urlGenerator ) {
68+ IURLGenerator $ urlGenerator ,
69+ ITimeFactory $ timeFactory ) {
6370 $ this ->logger = $ logger ;
6471 $ this ->appData = $ appDataFactory ->get ('css ' );
6572 $ this ->urlGenerator = $ urlGenerator ;
73+ $ this ->timeFactory = $ timeFactory ;
6674
6775 try {
6876 $ this ->folder = $ this ->appData ->getFolder ('icons ' );
@@ -131,6 +139,11 @@ public function getCachedCSS() {
131139 }
132140
133141 public function injectCss () {
142+ $ mtime = $ this ->timeFactory ->getTime ();
143+ $ file = $ this ->getCachedCSS ();
144+ if ($ file ) {
145+ $ mtime = $ file ->getMTime ();
146+ }
134147 // Only inject once
135148 foreach (\OC_Util::$ headers as $ header ) {
136149 if (
@@ -140,8 +153,8 @@ public function injectCss() {
140153 return ;
141154 }
142155 }
143- $ linkToCSS = $ this ->urlGenerator ->linkToRoute ('core.Css.getCss ' , ['appName ' => 'icons ' , 'fileName ' => $ this ->fileName ]);
156+ $ linkToCSS = $ this ->urlGenerator ->linkToRoute ('core.Css.getCss ' , ['appName ' => 'icons ' , 'fileName ' => $ this ->fileName , ' v ' => $ mtime ]);
144157 \OC_Util::addHeader ('link ' , ['rel ' => 'stylesheet ' , 'href ' => $ linkToCSS ], null , true );
145158 }
146159
147- }
160+ }
0 commit comments