nvaccess / nvda

NVDA, the free and open source Screen Reader for Microsoft Windows
Other
2.09k stars 628 forks source link

Better handling of too less free storage during creating a portable copy of NVDA #9967

Open DrSooom opened 5 years ago

DrSooom commented 5 years ago

Steps to reproduce:

  1. Use a USB flash drive with less than 110 MB free storage.
  2. Create a portable copy of NVDA on that device.

Note: I haven't tested the behavior if the checkbox "Launch the portable version after creation" (back-translation from German) is enabled.

Actual behavior:

Error message (from NVDA 2019.1.1):

The following useless message appears during the creation process:

Portable Version konnte nicht erstellt werden: error 112 copying \?\C:\Users\DANIEL~1\AppData\Local\Temp\nse7F24.tmp\app\locale\sq\LC_MESSAGES\nvda.mo to \?\P:\Sonstige Programme\NVDA 2019.1.1\locale\sq\LC_MESSAGES\nvda.mo

Logfile entries (from NVDA 2019.2 Beta-18133):

ERROR - gui.installerGui.doCreatePortable (17:17:09.634):
Failed to create portable copy
Traceback (most recent call last):
  File "gui\installerGui.pyc", line 355, in doCreatePortable
  File "gui\__init__.pyc", line 913, in __init__
OSError: error 112 copying \\?\C:\Users\DANIEL~1\AppData\Local\Temp\nsmFBD2.tmp\app\locale\ro\cldr.dic to \\?\P:\Sonstige Programme\NVDA 2019.1.1\locale\ro\cldr.dic

Expected behavior:

Solution 1:

The Installer should figure out how much free storage is available on the chosen device. If it's less than 128 MB, the following message should appear before the creation process starts:

System configuration

NVDA installed/portable/running from source:

Running from the Installer.

NVDA version:

2019.1.1 and 2019.2 Beta-18133

Windows version:

Win7x64

Other questions

Does the issue still occur after restarting your PC?

Not relevant. Not tested.

Have you tried any other versions of NVDA? If so, please report their behaviors.

Same result with NVDA 2019.2 Beta-18133.

Brian1Gaff commented 5 years ago

One comment though, I suspect many will want to use a copy of their current version including add ons so this will still fail as there seems no obvious way to stop that. Of course you could simply copy the existing files and user settings from the secure area and in that case you could find out exactly how big it was. Brian

bglists@blueyonder.co.uk Sent via blueyonder. Please address personal E-mail to:- briang1@blueyonder.co.uk, putting 'Brian Gaff' in the display name field. Newsgroup monitored: alt.comp.blind-users ----- Original Message ----- From: "Daniel Mayr" notifications@github.com To: "nvaccess/nvda" nvda@noreply.github.com Cc: "Subscribed" subscribed@noreply.github.com Sent: Wednesday, July 24, 2019 5:03 PM Subject: [nvaccess/nvda] Better handling of too less free storage during creating a portable copy of NVDA (#9967)

Steps to reproduce:

  1. Use a USB flash drive with less than 110 MB free storage.
  2. Create a portable copy of NVDA on that device.

Note: I haven't tested the behavior if the checkbox "Launch the portable version after creation" (back-translation from German) is enabled.

Actual behavior:

Error message (from NVDA 2019.1.1):

The following useless message appears during the creation process:

Portable Version konnte nicht erstellt werden: error 112 copying \?\C:\Users\DANIEL~1\AppData\Local\Temp\nse7F24.tmp\app\locale\sq\LC_MESSAGES\nvda.mo to \?\P:\Sonstige Programme\NVDA 2019.1.1\locale\sq\LC_MESSAGES\nvda.mo

Logfile entries (from NVDA 2019.2 Beta-18133):


Failed to create portable copy
Traceback (most recent call last):
 File "gui\installerGui.pyc", line 355, in doCreatePortable
 File "gui\__init__.pyc", line 913, in __init__
OSError: error 112 copying 
\\?\C:\Users\DANIEL~1\AppData\Local\Temp\nsmFBD2.tmp\app\locale\ro\cldr.dic 
to \\?\P:\Sonstige Programme\NVDA 2019.1.1\locale\ro\cldr.dic```

### Expected behavior:
#### Solution 1:
The Installer should figure out how much free storage is available on the 
chosen device. If it's less than 128 MB, the following message should 
appear before the creation process starts:
+ [Text] There isn't enough free storage on the chosen destination device 
to create a portable copy of NVDA. NVDA without add-ons requires 128 MB 
free storage.
+ [Button] OK
#### Solution 2:
Replace this technical error message with the following text messages:
1. Error message during the creation process:
  + [Text] There isn't enough free storage on the chosen destination 
device to create a portable copy of NVDA. NVDA without add-ons requires 
128 MB free storage. By pressing "OK" all already copied files for the 
portable copy of NVDA will be deleted, as the creation process couldn't be 
finalized.
  + [Button] OK
2. After all already copied files were deleted:
  + [Text] The uncompleted portable copy of NVDA was successfully removed.
  + [Button] OK
#### Update the system requirements for NVDA (website and User Guide):
Quote from my e-mail to NV Access on May 1st, 2019:
> URL: https://www.nvaccess.org/about-nvda/#features

Please change the following from
Memory: 256 mb or more of RAM
Processor speed: 1.0 ghz or above
About 90 MB of storage space.

to
Memory: 1 GB (32-bit until Win10-1511), otherwise 2 GB (64-bit, since 
Win10-1603 32-bit) or more of RAM
Processor speed: 1.0 GHz or above
About 120 MB of storage space.

Win7 alone requires 1 respectively 2 GB RAM. Win10 requires 2 GB (32- and 
64-bit).

### System configuration
#### NVDA installed/portable/running from source:
Running from the Installer.
#### NVDA version:
2019.1.1 and 2019.2 Beta-18133
#### Windows version:
Win7x64
### Other questions
#### Does the issue still occur after restarting your PC?
Not relevant. Not tested.
#### Have you tried any other versions of NVDA? If so, please report their 
behaviors.
Same result with NVDA 2019.2 Beta-18133.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/nvaccess/nvda/issues/9967 
josephsl commented 2 months ago

Hi,

Five years later...

The issue might be solvable if we can calculate the storage space needed before copying data to a USB drive. Depending on the scenario, this may or may not work:

  1. Instaled copy -> portable copy: yes if copying only NVDA program data, no if copying add-ons and other user data as well
  2. Launcher -> portable copy generation: yes if the original file sizes can be calculated and excluding user data, no if user data is to be copied

As an alternative, we should clarify in the user guide about system requirements, including noting the fact that disk space requirement is applicable when generating portable copy as well.

CC @Qchristensen

Thanks.

DrSooom commented 2 months ago

Quick (and dirty) Python script written by ChatGPT-4o. Use it as a draft.

import os
import shutil

# Resolve the path for the configuration directory using the APPDATA environment variable
config_directory = os.path.join(os.getenv('APPDATA'), 'nvda')
program_directory = r"C:\Program Files (x86)\NVDA"
drive_letter = "E:\\"

# Variables to store the total file sizes
install_portable_requspace_config = 0
install_portable_requspace_prog = 0
install_portable_freespace_targetdrive = 0
install_portable_requspace_total = 0
install_portable_freespace_valid = False

def calculate_directory_size(directory):
    total_size = 0
    for root, dirs, files in os.walk(directory):
        for file in files:
            file_path = os.path.join(root, file)
            total_size += os.path.getsize(file_path)
    return total_size

# Calculate the total file size in the configuration directory
install_portable_requspace_config = calculate_directory_size(config_directory)

# Calculate the total file size in the program directory
install_portable_requspace_prog = calculate_directory_size(program_directory)

# Determine the free space on drive E:\
total, used, free = shutil.disk_usage(drive_letter)
install_portable_freespace_targetdrive = free

# Add the total file sizes
install_portable_requspace_total = install_portable_requspace_config + install_portable_requspace_prog

# Check if there is enough free space
if install_portable_requspace_total < install_portable_freespace_targetdrive:
    install_portable_freespace_valid = True

# Output the total file sizes and the free space (in bytes)
print(f"Total file size in the configuration directory: {install_portable_requspace_config} Bytes")
print(f"Total file size in the program directory: {install_portable_requspace_prog} Bytes")
print(f"Free space on drive E: {install_portable_freespace_targetdrive} Bytes")
print(f"Total file size: {install_portable_requspace_total} Bytes")
print(f"Is there enough free space: {install_portable_freespace_valid}")