示例#1
0
        private bool PurgeToolFileSystem(DeviceTool deviceTool)
        {
            bool result = false;

            foreach (var payload in deviceTool.PayloadSet)
            {
                result = PurgeToolFileSystem(payload);

                if (result)
                {
                    MsgLogger.WriteFlow($"{GetType().Name} - CleanupToolStorage", $"payload file name {payload.FileName} deleted from file system");
                }
            }

            return(result);
        }
        private async Task <bool> DownloadTool(DeviceTool deviceTool)
        {
            bool result = false;

            foreach (var payload in deviceTool.PayloadSet)
            {
                var pluginCacheItem = FindPluginInCache(payload);

                if (pluginCacheItem != null)
                {
                    MsgLogger.WriteFlow($"{GetType().Name} - DownloadTool", $"payload file name {payload.FileName} found in cache");
                    result = true;
                }
                else
                {
                    pluginCacheItem = FindPluginInFileSystem(payload);

                    if (pluginCacheItem != null)
                    {
                        MsgLogger.WriteFlow($"{GetType().Name} - DownloadTool", $"payload file name {payload.FileName} found in file system");
                        result = true;
                    }
                    else
                    {
                        if (await DownloadTool(payload.Id, payload.HashCode, payload.Mode))
                        {
                            result = UpdatePluginCache(payload);
                        }
                        else
                        {
                            MsgLogger.WriteError($"{GetType().Name} - DownloadTool", $"payload file name {payload.FileName} download failed!");
                        }
                    }
                }
            }

            return(result);
        }