Skip to content

Ensure backup directory exists#2441

Closed
dail8859 wants to merge 1 commit intonotepad-plus-plus:masterfrom
dail8859:safer-backup
Closed

Ensure backup directory exists#2441
dail8859 wants to merge 1 commit intonotepad-plus-plus:masterfrom
dail8859:safer-backup

Conversation

@dail8859
Copy link
Copy Markdown
Contributor

@dail8859 dail8859 commented Oct 18, 2016

Closes #2346

The root cause of #2346 is a non-existing directory, and then the function returned false which aborted the save. This addresses the issue along with a few other tweaks:

  • Ensures the full directory exists. Just calling CreateDirectory() is not sufficient since multiple sub folders may not exist.
  • Failed backups result in a user error message but asks to save the current file anyways.
  • Applies to both simple and verbose backups.
  • Simplifies logic within fileSave() when figuring out where to save backups.

The new error message looks like this:

capture

{
*p = 0;
// May or may not already exist
::CreateDirectory(tmpName, NULL);
Copy link
Copy Markdown
Contributor

@SinghRajenM SinghRajenM Oct 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead calling CreateDirectory for each folder which may already exist (till ....\Roaming\Notepad++),
SHCreateDirectory can be used on fullpath. Whole logic of method createFullDirectory can be fallback option for SHCreateDirectory.

MSDN remark for SHCreateDirectory -
This function creates a file system folder whose fully qualified path is given by pszPath. If one or more of the intermediate folders do not exist, it creates them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did take a look at that. However that function is located under the deprecated API...and reading the documentation for it states:

SHCreateDirectory is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.

It did appear to work in my Win7 machine but I don't know if it works for Win8 or Win10...or how long into the future it will be supported.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are using these SH APIs (of course SHCreateDirectory as well) in production projects. These APIs work fine for win8 and Win10.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's really good to know! I'd much prefer to use SHCreateDirectory anyways. I'm never sure how serious to take the "warnings" from Microsoft about certain functions. I will update the PR when I get a chance.

Thanks!

Failed backups result in a user error message and asks to save the file anyways. Closes notepad-plus-plus#2346
@dail8859
Copy link
Copy Markdown
Contributor Author

PR updated.

@donho donho added the accepted label Oct 23, 2016
@donho donho added this to the 7.x (master) milestone Oct 23, 2016
@dail8859 dail8859 closed this in a82d9f9 Oct 24, 2016
@dail8859 dail8859 deleted the safer-backup branch October 24, 2016 01:11
SinghRajenM added a commit to SinghRajenM/notepad-plus-plus that referenced this pull request Nov 11, 2016
* Update german.xml to version 7.0 - 14.10.16

including last updates following english.xml from 14.10.2016

Closes notepad-plus-plus#2423

* Update translations

* Update farsi.xml to 7.1

* Update slovenian.xml to v7.1

* Notepad++ 7.1 release

* Updated hindi.xml

Closes notepad-plus-plus#2375

* Update config.model.xml

* config.xml is generated by notepad++

No more config.model.xml. config.xml is generated by notepad++ directly.

* Add SmartHighLight node for config.xml generation

* Fixed disable smart highlihgt inconsistent behaviour

This bug can be reproduce by turning off smart highlight then restart
Notepad++ : some smart highlight options are still enabled.

Fixes notepad-plus-plus#2442, closes notepad-plus-plus#2465

* Add .profile, .bash_profile, and .bashrc extensions.

* Ensure backup directory exists

Failed backups result in a user error message and asks to save the file anyways. Closes notepad-plus-plus#2346, Closes notepad-plus-plus#2441

* Add smart highlighting extension to anothe view option

Add new option to enable smat highlighting extension to anothe view,
while both views are visible side by side.

* Fix a regression of double click on several zones of status bar.

* Fix a tab settings regression

Tab settings per language broken due to the entries are doubled by error
during the preferences dialog reorganization.

* Fix uninstaller silent mode issue

Remove also unecessary files

* Fix Installer for 64-bit fails with argument "/D"

* Change styler to make makefile more readable

Closes notepad-plus-plus#2482

* MinGW GCC update

- changes necessary to get back a buildable version with mingw, last adapted with notepad-plus-plus#1229
- fixed some gcc compiler errors and warnings, see https://ci.appveyor.com/project/chcg/notepad-plus-plus/build/1.0.3 to https://ci.appveyor.com/project/chcg/notepad-plus-plus/build/1.0.13
- remaining task is the wincontrol "ReadDirectoryChanges", which uses ATL, propably not available with mingw
Closes notepad-plus-plus#2478

* Japanese translation update

* update translations to v7.1
* correct indent
Closes notepad-plus-plus#2436

* Update Ukrainian translation

Closes notepad-plus-plus#2414

* Update catalan.xml

Update to v7.0

Closes notepad-plus-plus#2412

* Fix Encoding radio button issue in New Document

Sync UTF-8 checkbox with UTF-8 radio button

Closes notepad-plus-plus#2377

* cmake config update

- added usable cmake config file by transferring files structure from visual studio project file
- contains also basic support for mingw make file creation
- see https://ci.appveyor.com/project/chcg/notepad-plus-plus/build/1.0.38 for successful with own appveyor config

Closes notepad-plus-plus#2477

* Update translations

* Notepad++ release 7.2

* Expand environment variables in backup path

Fixes notepad-plus-plus#2520, Fixes notepad-plus-plus#2525

* Improve Javascript readability
SinghRajenM added a commit to SinghRajenM/notepad-plus-plus that referenced this pull request Nov 11, 2016
* Update german.xml to version 7.0 - 14.10.16

including last updates following english.xml from 14.10.2016

Closes notepad-plus-plus#2423

* Update translations

* Update farsi.xml to 7.1

* Update slovenian.xml to v7.1

* Notepad++ 7.1 release

* Updated hindi.xml

Closes notepad-plus-plus#2375

* Update config.model.xml

* config.xml is generated by notepad++

No more config.model.xml. config.xml is generated by notepad++ directly.

* Add SmartHighLight node for config.xml generation

* Fixed disable smart highlihgt inconsistent behaviour

This bug can be reproduce by turning off smart highlight then restart
Notepad++ : some smart highlight options are still enabled.

Fixes notepad-plus-plus#2442, closes notepad-plus-plus#2465

* Add .profile, .bash_profile, and .bashrc extensions.

* Ensure backup directory exists

Failed backups result in a user error message and asks to save the file anyways. Closes notepad-plus-plus#2346, Closes notepad-plus-plus#2441

* Add smart highlighting extension to anothe view option

Add new option to enable smat highlighting extension to anothe view,
while both views are visible side by side.

* Fix a regression of double click on several zones of status bar.

* Fix a tab settings regression

Tab settings per language broken due to the entries are doubled by error
during the preferences dialog reorganization.

* Fix uninstaller silent mode issue

Remove also unecessary files

* Fix Installer for 64-bit fails with argument "/D"

* Change styler to make makefile more readable

Closes notepad-plus-plus#2482

* MinGW GCC update

- changes necessary to get back a buildable version with mingw, last adapted with notepad-plus-plus#1229
- fixed some gcc compiler errors and warnings, see https://ci.appveyor.com/project/chcg/notepad-plus-plus/build/1.0.3 to https://ci.appveyor.com/project/chcg/notepad-plus-plus/build/1.0.13
- remaining task is the wincontrol "ReadDirectoryChanges", which uses ATL, propably not available with mingw
Closes notepad-plus-plus#2478

* Japanese translation update

* update translations to v7.1
* correct indent
Closes notepad-plus-plus#2436

* Update Ukrainian translation

Closes notepad-plus-plus#2414

* Update catalan.xml

Update to v7.0

Closes notepad-plus-plus#2412

* Fix Encoding radio button issue in New Document

Sync UTF-8 checkbox with UTF-8 radio button

Closes notepad-plus-plus#2377

* cmake config update

- added usable cmake config file by transferring files structure from visual studio project file
- contains also basic support for mingw make file creation
- see https://ci.appveyor.com/project/chcg/notepad-plus-plus/build/1.0.38 for successful with own appveyor config

Closes notepad-plus-plus#2477

* Update translations

* Notepad++ release 7.2

* Expand environment variables in backup path

Fixes notepad-plus-plus#2520, Fixes notepad-plus-plus#2525

* Improved Run Macro dialog UI.
1. Radio button and edit box were overlapped
2. Edit box and comboxed were not vertically aligned.
SinghRajenM added a commit to SinghRajenM/notepad-plus-plus that referenced this pull request Nov 11, 2016
* Update german.xml to version 7.0 - 14.10.16

including last updates following english.xml from 14.10.2016

Closes notepad-plus-plus#2423

* Update translations

* Update farsi.xml to 7.1

* Update slovenian.xml to v7.1

* Notepad++ 7.1 release

* Updated hindi.xml

Closes notepad-plus-plus#2375

* Update config.model.xml

* config.xml is generated by notepad++

No more config.model.xml. config.xml is generated by notepad++ directly.

* Add SmartHighLight node for config.xml generation

* Fixed disable smart highlihgt inconsistent behaviour

This bug can be reproduce by turning off smart highlight then restart
Notepad++ : some smart highlight options are still enabled.

Fixes notepad-plus-plus#2442, closes notepad-plus-plus#2465

* Add .profile, .bash_profile, and .bashrc extensions.

* Ensure backup directory exists

Failed backups result in a user error message and asks to save the file anyways. Closes notepad-plus-plus#2346, Closes notepad-plus-plus#2441

* Add smart highlighting extension to anothe view option

Add new option to enable smat highlighting extension to anothe view,
while both views are visible side by side.

* Fix a regression of double click on several zones of status bar.

* Fix a tab settings regression

Tab settings per language broken due to the entries are doubled by error
during the preferences dialog reorganization.

* Fix uninstaller silent mode issue

Remove also unecessary files

* Fix Installer for 64-bit fails with argument "/D"

* Change styler to make makefile more readable

Closes notepad-plus-plus#2482

* MinGW GCC update

- changes necessary to get back a buildable version with mingw, last adapted with notepad-plus-plus#1229
- fixed some gcc compiler errors and warnings, see https://ci.appveyor.com/project/chcg/notepad-plus-plus/build/1.0.3 to https://ci.appveyor.com/project/chcg/notepad-plus-plus/build/1.0.13
- remaining task is the wincontrol "ReadDirectoryChanges", which uses ATL, propably not available with mingw
Closes notepad-plus-plus#2478

* Japanese translation update

* update translations to v7.1
* correct indent
Closes notepad-plus-plus#2436

* Update Ukrainian translation

Closes notepad-plus-plus#2414

* Update catalan.xml

Update to v7.0

Closes notepad-plus-plus#2412

* Fix Encoding radio button issue in New Document

Sync UTF-8 checkbox with UTF-8 radio button

Closes notepad-plus-plus#2377

* cmake config update

- added usable cmake config file by transferring files structure from visual studio project file
- contains also basic support for mingw make file creation
- see https://ci.appveyor.com/project/chcg/notepad-plus-plus/build/1.0.38 for successful with own appveyor config

Closes notepad-plus-plus#2477

* Update translations

* Notepad++ release 7.2

* Expand environment variables in backup path

Fixes notepad-plus-plus#2520, Fixes notepad-plus-plus#2525

* Update readme.txt

* Improve Javascript string readability

Fixes notepad-plus-plus#1543, closes notepad-plus-plus#2550

* Small tune on Run Macro dialog UI.

1. Radio button and edit box were overlapped
2. Edit box and comboxed were not vertically aligned.

Closes notepad-plus-plus#2549

* Remove 32bit shell dll from 64bit installer

Closes notepad-plus-plus#2408
anil-shrestha pushed a commit to anil-shrestha/notepad-plus-plus that referenced this pull request Dec 7, 2016
Failed backups result in a user error message and asks to save the file anyways. Closes notepad-plus-plus#2346, Closes notepad-plus-plus#2441
iczelia pushed a commit to iczelia/notepad-plus-plus that referenced this pull request Jan 17, 2021
Failed backups result in a user error message and asks to save the file anyways. Closes notepad-plus-plus#2346, Closes notepad-plus-plus#2441
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants