SanitizeTarPathMember() публичный статический Метод

public static SanitizeTarPathMember ( string member ) : string
member string
Результат string
Пример #1
0
        protected override void Run()
        {
            host.Status = HostStatus.compiling;

            string hostname = Helpers.GetName(host.Host);

            hostname = ZipStatusReportAction.SanitizeTarPathMember(hostname);
            // Workaround for excessively long filenames: trim the hostname we use
            if (hostname.Length > 20)
            {
                hostname = hostname.Truncate(20);
            }
            string filename = string.Format("{1}\\{2}-bugtool-{0}.tar", hostname, filepath, timestring);

            string entries_string = String.Join(",", entries);

            log.DebugFormat("Getting system status for {0} on {1}", entries_string, hostname);

            try
            {
                host.Status = HostStatus.compiling;
                if (Session == null)
                {
                    throw new Exception(Messages.CONNECTION_IO_EXCEPTION);
                }

                HTTPHelper.Get(this, false, dataRxDelegate, filename, host.Host.address,
                               (HTTP_actions.get_ssss)HTTP_actions.get_system_status,
                               Session.opaque_ref, entries_string, "tar");

                log.DebugFormat("Getting system status from {0} successful", hostname);

                host.Status          = HostStatus.succeeded;
                base.PercentComplete = 100;
            }
            catch (CancelledException ce)
            {
                log.Info("Getting system status cancelled");

                Description = Messages.ACTION_SYSTEM_STATUS_CANCELLED;
                host.Status = HostStatus.failed;
                host.error  = ce;

                throw;
            }
            catch (Exception e)
            {
                log.Warn(string.Format("Getting system status from {0} failed", hostname), e);

                host.Status = HostStatus.failed;
                host.error  = e;

                Description =
                    Win32.GetHResult(e) == Win32.ERROR_DISK_FULL ?
                    Messages.ACTION_SYSTEM_STATUS_DISK_FULL :
                    Messages.ACTION_SYSTEM_STATUS_FAILED;
            }
        }
Пример #2
0
        protected override void Run()
        {
            Status = ReportStatus.compiling;

            string hostname = Helpers.GetName(host);

            hostname = ZipStatusReportAction.SanitizeTarPathMember(hostname);
            if (hostname.Length > 20)
            {
                hostname = hostname.Truncate(20);
            }

            string filename = string.Format("{1}\\{2}-bugtool-{0}.tar", hostname, filePath, timeString);

            string entries_string = string.Join(",", capabilityKeys);

            log.DebugFormat("Getting system status for {0} on {1}", entries_string, hostname);

            try
            {
                if (Session == null)
                {
                    throw new Exception(Messages.CONNECTION_IO_EXCEPTION);
                }

                HTTPHelper.Get(this, false, dataRxDelegate, filename, host.address,
                               (HTTP_actions.get_ssss)HTTP_actions.get_system_status,
                               Session.opaque_ref, entries_string, "tar");

                log.DebugFormat("Getting system status from {0} successful", hostname);

                Status          = ReportStatus.succeeded;
                Description     = Messages.COMPLETED;
                PercentComplete = 100;
            }
            catch (HTTP.CancelledException)
            {
                throw new CancelledException();
            }
            catch (CancelledException ce)
            {
                log.Info("Getting system status cancelled");
                Status      = ReportStatus.cancelled;
                Error       = ce;
                Description = Messages.ACTION_SYSTEM_STATUS_CANCELLED;
                throw;
            }
            catch (Exception e)
            {
                log.Error(string.Format("Getting system status from {0} failed", hostname), e);

                Status = ReportStatus.failed;
                Error  = e;

                if (Win32.GetHResult(e) == Win32.ERROR_DISK_FULL)
                {
                    Description = Messages.ACTION_SYSTEM_STATUS_DISK_FULL;
                    return;
                }

                if (!string.IsNullOrEmpty(Error.Message) && RBAC_FAIL_STRINGS.All(s => Error.Message.Contains(s)))
                {
                    var roles = Host.Connection.Session.Roles;
                    roles.Sort();
                    Description = string.Format(Messages.BUGTOOL_RBAC_FAILURE, roles[0].FriendlyName());
                    return;
                }

                Description = Messages.BUGTOOL_REPORTSTATUS_FAILED;
            }
        }