12-27-2023, 09:35 PM
It just depends on how you want to do it. Having them all in the same cache folder is fine, but it just will not get cleaned up if the service is stopped.
So we separate them and then use the following code in the startup of the servercontroller just to make sure everything is cleaned up.
if SystemParams.ServerControllerParams.CacheDir <> '' then
begin
// Clear the cache directory to make sure that the temp folder is empty on startup,
// Check to make sure that it is not using the windows temp directory
if POS('windows',lowercase(SystemParams.ServerControllerParams.CacheDir)) = 0 then
begin
If SysUtils.DirectoryExists(trim(SystemParams.ServerControllerParams.CacheDir)) then
System.IOUtils.TDirectory.Delete(trim(SystemParams.ServerControllerParams.CacheDir),true);
end;
// Now recreate it
if Sysutils.ForceDirectories(SystemParams.ServerControllerParams.CacheDir) then
CacheDir := SystemParams.ServerControllerParams.CacheDir;
// Now recreate the Downloads directory (used for streaming non IW cache files)
if Sysutils.ForceDirectories(SystemParams.ServerControllerParams.CacheDir + '\Downloads') then
gDownloadDir := SystemParams.ServerControllerParams.CacheDir + '\Downloads\';
end;
So we separate them and then use the following code in the startup of the servercontroller just to make sure everything is cleaned up.
if SystemParams.ServerControllerParams.CacheDir <> '' then
begin
// Clear the cache directory to make sure that the temp folder is empty on startup,
// Check to make sure that it is not using the windows temp directory
if POS('windows',lowercase(SystemParams.ServerControllerParams.CacheDir)) = 0 then
begin
If SysUtils.DirectoryExists(trim(SystemParams.ServerControllerParams.CacheDir)) then
System.IOUtils.TDirectory.Delete(trim(SystemParams.ServerControllerParams.CacheDir),true);
end;
// Now recreate it
if Sysutils.ForceDirectories(SystemParams.ServerControllerParams.CacheDir) then
CacheDir := SystemParams.ServerControllerParams.CacheDir;
// Now recreate the Downloads directory (used for streaming non IW cache files)
if Sysutils.ForceDirectories(SystemParams.ServerControllerParams.CacheDir + '\Downloads') then
gDownloadDir := SystemParams.ServerControllerParams.CacheDir + '\Downloads\';
end;

