View on GitHub
File Changes
m
+1/-0

                      
### Fixes

                      
+
- Implemented disk space check error handling ([PR 1562](https://github.com/input-output-hk/daedalus/pull/1562))
- Fixed UI issues across different app themes ([PR 1547](https://github.com/input-output-hk/daedalus/pull/1547))
- Fixed minor UI issues on the "Delegation center" screen and "Delegation setup" wizard ([PR 1545](https://github.com/input-output-hk/daedalus/pull/1545))
- Fixed "White" theme styles ([PR 1532](https://github.com/input-output-hk/daedalus/pull/1532))
// Make sure Daedalus is started with required configuration
const { LAUNCHER_CONFIG } = process.env;
const isStartedByLauncher = !!LAUNCHER_CONFIG;
+
const isWindows = process.platform === 'win32';
if (!isStartedByLauncher) {
-
  const isWindows = process.platform === 'win32';
  const dialogTitle = 'Daedalus improperly started!';
  let dialogMessage;
  if (isProduction) {
export const appFolderPath = launcherConfig.workingDir;
export const { nodeDbPath } = launcherConfig;
export const stateDirectoryPath = launcherConfig.statePath;
+
export const stateDrive = isWindows ? stateDirectoryPath.slice(0, 2) : '/';
export const ALLOWED_LOGS = [
  'Daedalus.json',
  'System-info.json',
import checkDiskSpace from 'check-disk-space';
import prettysize from 'prettysize';
import { getDiskSpaceStatusChannel } from '../ipc/get-disk-space-status';
-
import { environment } from '../environment';
import { Logger } from './logging';
import {
  DISK_SPACE_REQUIRED,
  DISK_SPACE_CHECK_MEDIUM_INTERVAL,
  DISK_SPACE_CHECK_SHORT_INTERVAL,
  DISK_SPACE_RECOMMENDED_PERCENTAGE,
+
  stateDrive,
} from '../config';

                      
export const handleDiskSpace = (
  mainWindow: BrowserWindow,
  onCheckDiskSpace?: Function
) => {
-
  const path = environment.isWindows ? 'C:' : '/';
  let diskSpaceCheckInterval;
  let diskSpaceCheckIntervalLength = DISK_SPACE_CHECK_LONG_INTERVAL; // Default check interval
  let isNotEnoughDiskSpace = false; // Default check state

                      
  const handleCheckDiskSpace = async (forceDiskSpaceRequired?: number) => {
    const diskSpaceRequired = forceDiskSpaceRequired || DISK_SPACE_REQUIRED;
-
    const {
-
      free: diskSpaceAvailable,
-
      size: diskTotalSpace,
-
    } = await checkDiskSpace(path);
-
    const diskSpaceMissing = Math.max(
-
      diskSpaceRequired - diskSpaceAvailable,
-
      0
-
    );
-
    const diskSpaceRecommended =
-
      (diskTotalSpace * DISK_SPACE_RECOMMENDED_PERCENTAGE) / 100;
-
    const diskSpaceRequiredMargin =
-
      diskSpaceRequired -
-
      (diskSpaceRequired * DISK_SPACE_REQUIRED_MARGIN_PERCENTAGE) / 100;
+
    try {
+
      const {
+
        free: diskSpaceAvailable,
+
        size: diskTotalSpace,
+
      } = await checkDiskSpace(stateDrive);
+
      const diskSpaceMissing = Math.max(
+
        diskSpaceRequired - diskSpaceAvailable,
+
        0
+
      );
+
      const diskSpaceRecommended =
+
        (diskTotalSpace * DISK_SPACE_RECOMMENDED_PERCENTAGE) / 100;
+
      const diskSpaceRequiredMargin =
+
        diskSpaceRequired -
+
        (diskSpaceRequired * DISK_SPACE_REQUIRED_MARGIN_PERCENTAGE) / 100;

                      
-
    if (diskSpaceAvailable <= diskSpaceRequiredMargin) {
-
      if (!isNotEnoughDiskSpace) {
-
        // State change: transitioning from enough to not-enough disk space
-
        setDiskSpaceIntervalChecking(DISK_SPACE_CHECK_SHORT_INTERVAL);
-
        isNotEnoughDiskSpace = true;
+
      if (diskSpaceAvailable <= diskSpaceRequiredMargin) {
+
        if (!isNotEnoughDiskSpace) {
+
          // State change: transitioning from enough to not-enough disk space
+
          setDiskSpaceIntervalChecking(DISK_SPACE_CHECK_SHORT_INTERVAL);
+
          isNotEnoughDiskSpace = true;
+
        }
+
      } else if (diskSpaceAvailable >= diskSpaceRequired) {
+
        const newDiskSpaceCheckIntervalLength =
+
          diskSpaceAvailable >= diskSpaceRequired * 2
+
            ? DISK_SPACE_CHECK_LONG_INTERVAL
+
            : DISK_SPACE_CHECK_MEDIUM_INTERVAL;
+
        if (isNotEnoughDiskSpace) {
+
          // State change: transitioning from not-enough to enough disk space
+
          setDiskSpaceIntervalChecking(newDiskSpaceCheckIntervalLength);
+
          isNotEnoughDiskSpace = false;
+
        } else if (
+
          newDiskSpaceCheckIntervalLength !== diskSpaceCheckIntervalLength
+
        ) {
+
          // Interval change: transitioning from medium to long interval (or vice versa)
+
          // This is a special case in which we adjust the disk space check polling interval:
+
          // - more than 2x of available space than required: LONG interval
+
          // - less than 2x of available space than required: MEDIUM interval
+
          setDiskSpaceIntervalChecking(newDiskSpaceCheckIntervalLength);
+
        }
      }
-
    } else if (diskSpaceAvailable >= diskSpaceRequired) {
-
      const newDiskSpaceCheckIntervalLength =
-
        diskSpaceAvailable >= diskSpaceRequired * 2
-
          ? DISK_SPACE_CHECK_LONG_INTERVAL
-
          : DISK_SPACE_CHECK_MEDIUM_INTERVAL;
-
      if (isNotEnoughDiskSpace) {
-
        // State change: transitioning from not-enough to enough disk space
-
        setDiskSpaceIntervalChecking(newDiskSpaceCheckIntervalLength);
-
        isNotEnoughDiskSpace = false;
-
      } else if (
-
        newDiskSpaceCheckIntervalLength !== diskSpaceCheckIntervalLength
-
      ) {
-
        // Interval change: transitioning from medium to long interval (or vice versa)
-
        // This is a special case in which we adjust the disk space check polling interval:
-
        // - more than 2x of available space than required: LONG interval
-
        // - less than 2x of available space than required: MEDIUM interval
-
        setDiskSpaceIntervalChecking(newDiskSpaceCheckIntervalLength);
+

                      
+
      const response = {
+
        isNotEnoughDiskSpace,
+
        diskSpaceRequired: prettysize(diskSpaceRequired),
+
        diskSpaceMissing: prettysize(diskSpaceMissing),
+
        diskSpaceRecommended: prettysize(diskSpaceRecommended),
+
        diskSpaceAvailable: prettysize(diskSpaceAvailable),
+
      };
+
      if (isNotEnoughDiskSpace)
+
        Logger.info('Not enough disk space', { response });
+
      if (typeof onCheckDiskSpace === 'function') onCheckDiskSpace(response);
+
      getDiskSpaceStatusChannel.send(response, mainWindow.webContents);
+
      return response;
+
    } catch (error) {
+
      // Remove diskSpaceCheckInterval if set
+
      if (diskSpaceCheckInterval) {
+
        clearInterval(diskSpaceCheckInterval);
+
        // Reset to default check interval
+
        diskSpaceCheckIntervalLength = DISK_SPACE_CHECK_LONG_INTERVAL;
      }
+
      const response = {
+
        isNotEnoughDiskSpace: false,
+
        diskSpaceRequired: '',
+
        diskSpaceMissing: '',
+
        diskSpaceRecommended: '',
+
        diskSpaceAvailable: '',
+
      };
+
      getDiskSpaceStatusChannel.send(response, mainWindow.webContents);
+
      return response;
    }
-

                      
-
    const response = {
-
      isNotEnoughDiskSpace,
-
      diskSpaceRequired: prettysize(diskSpaceRequired),
-
      diskSpaceMissing: prettysize(diskSpaceMissing),
-
      diskSpaceRecommended: prettysize(diskSpaceRecommended),
-
      diskSpaceAvailable: prettysize(diskSpaceAvailable),
-
    };
-
    if (isNotEnoughDiskSpace)
-
      Logger.info('Not enough disk space', { response });
-
    if (typeof onCheckDiskSpace === 'function') onCheckDiskSpace(response);
-
    getDiskSpaceStatusChannel.send(response, mainWindow.webContents);
-
    return response;
  };

                      
  const setDiskSpaceIntervalChecking = interval => {
    defaultMessage: '!!!Available disk space',
    description: 'Available disk space',
  },
+
  unknownDiskSpace: {
+
    id: 'daedalus.diagnostics.dialog.unknownDiskSpace',
+
    defaultMessage: '!!!Unknown',
+
    description: 'Unknown amount of disk space',
+
  },
+
  unknownDiskSpaceSupportUrl: {
+
    id: 'daedalus.diagnostics.dialog.unknownDiskSpaceSupportUrl',
+
    defaultMessage: '!!!https://iohk.zendesk.com/hc',
+
    description: '"Support" link URL while disk space is unknown',
+
  },
  coreInfo: {
    id: 'daedalus.diagnostics.dialog.coreInfo',
    defaultMessage: '!!!CORE INFO',
      styles[`locale-${currentLocale}`],
    ]);

                      
+
    const unknownDiskSpaceSupportUrl = intl.formatMessage(
+
      messages.unknownDiskSpaceSupportUrl
+
    );
+

                      
    return (
      <div className={styles.component}>
        <DialogCloseButton
              </tr>
              <tr>
                <th>{intl.formatMessage(messages.availableDiskSpace)}:</th>
-
                <td>{availableDiskSpace}</td>
+
                <td>
+
                  {availableDiskSpace || (
+
                    <button
+
                      className={styles.unknownDiskSpaceBtn}
+
                      onClick={() =>
+
                        onOpenExternalLink(unknownDiskSpaceSupportUrl)
+
                      }
+
                    >
+
                      {intl.formatMessage(messages.unknownDiskSpace)}
+
                      <SVGInline
+
                        svg={externalLinkIcon}
+
                        className={styles.externalLinkIcon}
+
                      />
+
                    </button>
+
                  )}
+
                </td>
              </tr>
            </tbody>
            <tbody>
      padding-top: 0;
    }

                      
-
    &.realTimeStatusBtn {
+
    &.realTimeStatusBtn,
+
    &.unknownDiskSpaceBtn {
      @include link(--theme-network-window-white-color);
      background: transparent !important;
      border-bottom: none;
  "daedalus.diagnostics.dialog.system.info": "SYSTEM INFO",
  "daedalus.diagnostics.dialog.systemTimeCorrect": "System Time Correct",
  "daedalus.diagnostics.dialog.systemTimeIgnored": "System Time Ignored",
+
  "daedalus.diagnostics.dialog.unknownDiskSpace": "!!!Unknown",
+
  "daedalus.diagnostics.dialog.unknownDiskSpaceSupportUrl": "!!!https://iohk.zendesk.com/hc",
  "environment.apiName.cardano": "!!!Cardano",
  "environment.currency.ada": "!!!Ada",
  "global.assuranceLevel.normal": "!!!Normal",
          "line": 57
        }
      },
+
      {
+
        "defaultMessage": "!!!Unknown",
+
        "description": "Unknown amount of disk space",
+
        "end": {
+
          "column": 3,
+
          "line": 66
+
        },
+
        "file": "source/renderer/app/components/status/DaedalusDiagnostics.js",
+
        "id": "daedalus.diagnostics.dialog.unknownDiskSpace",
+
        "start": {
+
          "column": 20,
+
          "line": 62
+
        }
+
      },
+
      {
+
        "defaultMessage": "!!!https://iohk.zendesk.com/hc",
+
        "description": "\"Support\" link URL while disk space is unknown",
+
        "end": {
+
          "column": 3,
+
          "line": 71
+
        },
+
        "file": "source/renderer/app/components/status/DaedalusDiagnostics.js",
+
        "id": "daedalus.diagnostics.dialog.unknownDiskSpaceSupportUrl",
+
        "start": {
+
          "column": 30,
+
          "line": 67
+
        }
+
      },
      {
        "defaultMessage": "!!!CORE INFO",
        "description": "CORE INFO",
        "end": {
          "column": 3,
-
          "line": 66
+
          "line": 76
        },
        "file": "source/renderer/app/components/status/DaedalusDiagnostics.js",
        "id": "daedalus.diagnostics.dialog.coreInfo",
        "start": {
          "column": 12,
-
          "line": 62
+
          "line": 72
        }
      },
      {
        "defaultMessage": "!!!Daedalus Version",
        "description": "Daedalus Version",
        "end": {
          "column": 3,
-
          "line": 71
+
          "line": 81
        },
        "file": "source/renderer/app/components/status/DaedalusDiagnostics.js",
        "id": "daedalus.diagnostics.dialog.daedalusVersion",
        "start": {
          "column": 19,
-
          "line": 67
+
          "line": 77
        }
      },
      {
        "defaultMessage": "!!!Daedalus Main Process ID",
        "description": "Daedalus Main Process ID",
        "end": {
          "column": 3,
-
          "line": 76
+
          "line": 86
        },
        "file": "source/renderer/app/components/status/DaedalusDiagnostics.js",
        "id": "daedalus.diagnostics.dialog.daedalusMainProcessID",
        "start": {
          "column": 25,
-
          "line": 72
+
          "line": 82
        }
      },
      {
        "defaultMessage": "!!!Daedalus Renderer Process ID",
        "description": "Daedalus Renderer Process ID",
        "end": {
          "column": 3,
-
          "line": 81
+
          "line": 91
        },
        "file": "source/renderer/app/components/status/DaedalusDiagnostics.js",
        "id": "daedalus.diagnostics.dialog.daedalusProcessID",
        "start": {
          "column": 21,
-
          "line": 77
+
          "line": 87
        }
      },
      {
        "defaultMessage": "!!!'Blank Screen Fix' active",
        "description": "'Blank Screen Fix' active",
        "end": {
          "column": 3,
-
          "line": 86
+
          "line": 96
        },
        "file": "source/renderer/app/components/status/DaedalusDiagnostics.js",
        "id": "daedalus.diagnostics.dialog.blankScreenFix",
        "start": {
          "column": 18,
-
          "line": 82
+
          "line": 92
        }
      },
      {
        "defaultMessage": "!!!Cardano Version",
        "description": "Cardano Version",
        "end": {
          "column": 3,
-
          "line": 91
+
          "line": 101
        },
        "file": "source/renderer/app/components/status/DaedalusDiagnostics.js",
        "id": "daedalus.diagnostics.dialog.cardanoVersion",
        "start": {
          "column": 18,
-
          "line": 87
+
          "line": 97
        }
      },
      {
        "defaultMessage": "!!!Cardano Process ID",
        "description": "Cardano Process ID",
        "end": {
          "column": 3,
-
          "line": 96
+
          "line": 106
        },
        "file": "source/renderer/app/components/status/DaedalusDiagnostics.js",
        "id": "daedalus.diagnostics.dialog.cardanoProcessID",
        "start": {
          "column": 20,
-
          "line": 92
+
          "line": 102
        }
      },
      {
        "defaultMessage": "!!!Cardano API Port",
        "description": "Cardano API Port",
        "end": {
          "column": 3,
-
          "line": 101
+
          "line": 111
        },
        "file": "source/renderer/app/components/status/DaedalusDiagnostics.js",
        "id": "daedalus.diagnostics.dialog.cardanoApiPort",
        "start": {
          "column": 18,
-
          "line": 97
+
          "line": 107
        }
      },
      {
        "defaultMessage": "!!!Cardano Network",
        "description": "Cardano Network",
        "end": {
          "column": 3,
-
          "line": 106
+
          "line": 116
        },
        "file": "source/renderer/app/components/status/DaedalusDiagnostics.js",
        "id": "daedalus.diagnostics.dialog.cardanoNetwork",
        "start": {
          "column": 18,
-
          "line": 102
+
          "line": 112
        }
      },
      {
        "defaultMessage": "!!!Daedalus State Directory",
        "description": "Daedalus State Directory",
        "end": {
          "column": 3,
-
          "line": 111
+
          "line": 121
        },
        "file": "source/renderer/app/components/status/DaedalusDiagnostics.js",
        "id": "daedalus.diagnostics.dialog.stateDirectory",
        "start": {
          "column": 22,
-
          "line": 107
+
          "line": 117
        }
      },
      {
        "defaultMessage": "!!!Open",
        "description": "Open",
        "end": {
          "column": 3,
-
          "line": 116
+
          "line": 126
        },
  "daedalus.diagnostics.dialog.system.info": "SYSTEM INFO",
  "daedalus.diagnostics.dialog.systemTimeCorrect": "System Time Correct",
  "daedalus.diagnostics.dialog.systemTimeIgnored": "System Time Ignored",
+
  "daedalus.diagnostics.dialog.unknownDiskSpace": "Unknown",
+
  "daedalus.diagnostics.dialog.unknownDiskSpaceSupportUrl": "https://iohk.zendesk.com/hc/en-us/articles/360035654533",
  "environment.apiName.cardano": "Cardano",
  "environment.currency.ada": "Ada",
  "global.assuranceLevel.normal": "Normal",
  "daedalus.diagnostics.dialog.system.info": "SYSTEM INFO",
  "daedalus.diagnostics.dialog.systemTimeCorrect": "System Time Correct",
  "daedalus.diagnostics.dialog.systemTimeIgnored": "System Time Ignored",
+
  "daedalus.diagnostics.dialog.unknownDiskSpace": "!!!Unknown",
+
  "daedalus.diagnostics.dialog.unknownDiskSpaceSupportUrl": "!!!https://iohk.zendesk.com/hc",
  "environment.apiName.cardano": "!!!Cardano",
  "environment.currency.ada": "!!!Ada",
  "global.assuranceLevel.normal": "!!!Normal",
  "daedalus.diagnostics.dialog.system.info": "システム情報",
  "daedalus.diagnostics.dialog.systemTimeCorrect": "システム時間正常",
  "daedalus.diagnostics.dialog.systemTimeIgnored": "システム時間無視",
+
  "daedalus.diagnostics.dialog.unknownDiskSpace": "不明",
+
  "daedalus.diagnostics.dialog.unknownDiskSpaceSupportUrl": "https://iohk.zendesk.com/hc/ja/articles/360035654533",
  "environment.apiName.cardano": "Cardano",
  "environment.currency.ada": "Ada",
  "global.assuranceLevel.normal": "普通",
  "daedalus.diagnostics.dialog.system.info": "SYSTEM INFO",
  "daedalus.diagnostics.dialog.systemTimeCorrect": "System Time Correct",
  "daedalus.diagnostics.dialog.systemTimeIgnored": "System Time Ignored",
+
  "daedalus.diagnostics.dialog.unknownDiskSpace": "!!!Unknown",
+
  "daedalus.diagnostics.dialog.unknownDiskSpaceSupportUrl": "!!!https://iohk.zendesk.com/hc",
  "environment.apiName.cardano": "!!!Cardano",
  "environment.currency.ada": "!!!Ada",
  "global.assuranceLevel.normal": "!!!Normal",
  "daedalus.diagnostics.dialog.system.info": "!!!SYSTEM INFO",
  "daedalus.diagnostics.dialog.systemTimeCorrect": "!!!System Time Correct",
  "daedalus.diagnostics.dialog.systemTimeIgnored": "!!!System Time Ignored",
+
  "daedalus.diagnostics.dialog.unknownDiskSpace": "!!!Unknown",
+
  "daedalus.diagnostics.dialog.unknownDiskSpaceSupportUrl": "!!!https://iohk.zendesk.com/hc",
  "environment.apiName.cardano": "!!!Cardano",
  "environment.currency.ada": "!!!Ada",
  "global.assuranceLevel.normal": "!!!Normal",