Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find part of the path #323

Closed
0x78f1935 opened this issue Oct 1, 2019 · 7 comments

Comments

@0x78f1935
Copy link

@0x78f1935 0x78f1935 commented Oct 1, 2019

Hello,

using XML data to provide a new version and everything seems to work fine.
I followed the code in the documentation in order to extract the zip file.
However System.IO.DirectoryNotFoundException raises.

I used a lot of provided methods in order to try debugging my issue. The settings Ive used:

       AutoUpdater.ShowSkipButton = false; // remove skip button
       AutoUpdater.ShowRemindLaterButton = false; // remove reminder button
       AutoUpdater.Mandatory = true; // Force update
       AutoUpdater.UpdateMode = Mode.Forced; // Set update mode
       AutoUpdater.RunUpdateAsAdmin = true;
       // AutoUpdater.OpenDownloadPage = true;
       AutoUpdater.ReportErrors = true;
       AutoUpdater.DownloadPath = AppDomain.CurrentDomain.BaseDirectory;

When looking into the DownloadPath I notice that the file is downloaded but not as a zip. Its downloaded as a .tmp file. My guess is that AutoUpdater.NET does this self. The zip file name contains a UUID. If I rename this file to .zip extension I can extract it without issue.

If i try to catch the error

                  try
                   {
                       AutoUpdater.DownloadUpdate();
                       //if (AutoUpdater.DownloadUpdate())
                       //{
                       //    System.Windows.Forms.Application.Exit();
                       //}
                   }
                   catch (System.IO.DirectoryNotFoundException)
                   {
                       Console.WriteLine("yay");
                   }

It does seem like the catch gets skipped over. So I am unable to catch the error myself.

My expectations would be to extract the zip and overwrite the current application with the new data. Then restart the app with the new version.

The following things do work however:

  • Update notification
  • Download new version
  • Changelog

The error rapport doesnt show me any additional information. (No report to be found). My disk gets loaded with all those downloaded UUID.TMP.
One thing I saw online was that i might use incorrect characters in the path name. But there are none. Except for perhaps a space. (This is in the computer name).

Any tips to solve this issue would be really appreciated.

@0x78f1935

This comment has been minimized.

Copy link
Author

@0x78f1935 0x78f1935 commented Oct 1, 2019

My Current workaround:

                            if (!AutoUpdater.DownloadUpdate()) // somehow this if is true when System.IO.DirectoryNotFoundException
                            {
                                string[] files = Directory.GetFiles(AutoUpdater.DownloadPath);
                                for (int i = 0; i < files.Length; i++) // Iterate through all downloaded files. looking for a .tmp extension
                                {
                                    var currentpath = files.GetValue(i); // Get the full path of the download
                                    if (currentpath.ToString().EndsWith(".tmp")) {
                                        var zippath = String.Concat(currentpath.ToString().Remove(currentpath.ToString().Length - 3), "zip");
                                        File.Move(currentpath.ToString(), zippath);
                                    }
                                }
                            }
@etisdew

This comment has been minimized.

Copy link

@etisdew etisdew commented Oct 1, 2019

Is anyone able to replicate the issue? On the topic of spaces and this might not be contextually relavent. I have always had to escape whitespace in pathnames by quoting them but my experience is in varied contexts. It never hurts to try escaping quotes for a pathname to see if it makes a difference but the only nugget as a random passerby I can offer.

@ravibpatel

This comment has been minimized.

Copy link
Owner

@ravibpatel ravibpatel commented Oct 1, 2019

Can you reference the AutoUpdater.NET project directly into your project? It will help pinpoint the issue.

@0x78f1935

This comment has been minimized.

Copy link
Author

@0x78f1935 0x78f1935 commented Oct 1, 2019

@ravibpatel Thank you for the quick reply, currently I dont have access to my source code since I forgot to push. I try your suggestion out when I do have access and I will keep you up to date. (tomorrow that is).

@etisdew In my sittuation I use the System.Environment way. To my knowledge there is not really a default way to escape blank characters, unless you apply some string magic. (correct me if i'm wrong).

Thanks again :)

@0x78f1935

This comment has been minimized.

Copy link
Author

@0x78f1935 0x78f1935 commented Oct 2, 2019

Hello Again, @ravibpatel, Like you mentioned referencing AutoUpdater.NET into the c# application has no effect. AutoUpdater is already referenced by in order to call the download.

The moment it goes down:
image

Therefor AutoUpdater.Net is enabled in the references. References > Add reference > Extensions > AutoUpdater.NET. I dont know if its helpfull but the package also comes from nugget.

@etisdew

This comment has been minimized.

Copy link

@etisdew etisdew commented Oct 2, 2019

In debug mode could you Console WriteLine or step into the value of the tempPath _tempPath and basicly anything with a path. The xml file contents. And the url of the initial check for xml? I straight up had two copys of the xml first setting up and forgot which one I was actually editing and which was for reference. I know its a derpy mistake but I admit being able to make it myself and it seems like the issue is gunna end up being something simple or quirky. I love the workaround but looking at examples of working implimentations, I think something is just missing or being string built into a cornercase.

What is the value of AutoUpdater.DownloadPath = AppDomain.CurrentDomain.BaseDirectory; I'm not a C# guy but I'll follow the docs to its definition and edit in if this is the issue. Does it not work for you to serve the .zip from an https endpoint?

@0x78f1935

This comment has been minimized.

Copy link
Author

@0x78f1935 0x78f1935 commented Oct 2, 2019

Thanks again for your reply @etisdew, I do serve the XML in a flask webapplication which serves the XML file over ssl. (unless debugging then i use a local network in order to use breakpoints). I only have one xml file on that server currently with the data needed to update.
The download path is basically the default path. (which is appdata/temp) on windows I believe. I ended up writing my own updater class following this video tutorial: https://www.youtube.com/playlist?list=PL3iOx6lykrwqc_KuJWIU3yAyTP2C7h_xE. It gave me a deeper understanding on how this actually works and I managed to pull it off too. So for me personally I dont really need AutoUpdater.Net anymore altho it has some nice additional features.

AppDomain.CurrentDomain.BaseDirectory references the current working dir. It might even be equivalent in python with os.getcwd() or pathlib.Path(file).
The documentation states that if AutoUpdater.DownloadPath is not set, then the default path would be:
C:\Users\My Name\AppData\Local\Temp\file.TMP. Note: "My Name" is not the actual computer name however it includes a space and is as long as the actual computer name.

I have trail and error this for about 2 more hours until i decided to write my own. I hope this ticket is helpful for anyone else who walks against this issue. Altho there is not really a solution I can provide.
Depending on what the state is of this issue, in my eyes this ticket can be closed.

@0x78f1935 0x78f1935 closed this Oct 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.