HISE Logo Forum
    • Categories
    • Register
    • Login

    Download / Error Message

    Scheduled Pinned Locked Moved General Questions
    12 Posts 3 Posters 268 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • d.healeyD
      d.healey @DanH
      last edited by

      @DanH

      Perhaps this would work

      if (abort || !Server.isOnline)
          this.abort();
      

      Libre Wave - Freedom respecting instruments and effects
      My Patreon - HISE tutorials
      YouTube Channel - Public HISE tutorials

      1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey
        last edited by d.healey

        I was just doing some work on my own downloader and I realised you don't need to do this check. What you need to do is only run the extraction if this.data.success == true.

        So you would do something like this.

        if (this.data.finished)
        {
            if (this.data.success)
                // extract the zip file
            else
                // show an error message
        }
        

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        DanHD 2 Replies Last reply Reply Quote 1
        • DanHD
          DanH @d.healey
          last edited by

          @d-healey I just woke up had the same thought, thanks!

          DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
          https://dhplugins.com/ | https://dcbreaks.com/
          London, UK

          1 Reply Last reply Reply Quote 0
          • DanHD
            DanH @d.healey
            last edited by

            @d-healey so that solved it, and I also added a command to delete the incomplete .zip file if the downloaded is aborted either by the user or lost connection. This prevents a duplicate file being created with a '(2)' suffix in the filename which will be inconsistent with the filename given to the extraction process, and ensures the correct file is unzipped.

            However.... this does not take into account the app being closed before the download is completed (for whatever reason, user shutdown etc). In that scenario the incomplete zip file is left there. The Server.download command doesn't overwrite the file; a duplicate will be created again as above.

            So, is there a way to check if that file exists before the download kicks in and, if it does, delete it?

            DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
            https://dhplugins.com/ | https://dcbreaks.com/
            London, UK

            LindonL 1 Reply Last reply Reply Quote 0
            • LindonL
              Lindon @DanH
              last edited by

              @DanH isnt it as simple as doing this before you begin the download...:

              // get dir first...then...
              
              e = dir.getChildFile("SAMPLES.zip");
              
              if(e.isFile())
              {
                  // it exists so delete it...
              }
              

              HISE Development for hire.
              www.channelrobot.com

              DanHD 1 Reply Last reply Reply Quote 0
              • DanHD
                DanH @Lindon
                last edited by

                @Lindon maybe, let me try! I always forget about the isFile option

                DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                https://dhplugins.com/ | https://dcbreaks.com/
                London, UK

                DanHD 1 Reply Last reply Reply Quote 0
                • DanHD
                  DanH @DanH
                  last edited by DanH

                  @Lindon So as I thought might happen it checks if the file exists, deletes it, but also executes the download at the same time and seems to delete it's own file perhaps.... The app downloads but not to a visible file and therefore can't unzip it when finished.

                  I've had to put the check in the startDownload function which occurs before my original code above. Is there a way to separate the check and the download process? Maybe another function....

                  inline function startDownload()
                  {	
                  	Engine.showYesNoWindow("SELECT FOLDER", "SELECT WHERE YOU WANT TO STORE THE SAMPLES", function(response)
                  	{
                  		
                  		if (response)
                  		{
                  
                  			FileSystem.browseForDirectory(downloadsFolder, function(dir)
                  			{
                  				if (isDefined(dir) && dir.isDirectory())
                  				{
                  
                  					Server.setBaseURL("https://mtfunkyURL");
                  					
                  					var f = dir.getChildFile("SAMPLES.zip");
                  					
                  					if(f.isFile())
                  					{
                  						f.deleteFileOrDirectory();
                  						download = Server.downloadFile(url, {}, f, downloadCallback);
                  					}
                  					
                  					else
                  					{
                  						download = Server.downloadFile(url, {}, f, downloadCallback);	
                  					}
                  								
                  				}		
                  			});
                  		}
                  	});
                  }
                  

                  DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                  https://dhplugins.com/ | https://dcbreaks.com/
                  London, UK

                  LindonL 1 Reply Last reply Reply Quote 0
                  • LindonL
                    Lindon @DanH
                    last edited by

                    @DanH why are you putting the check in the startDownload function?

                    Your program logic needs to reflect what you want to do

                    1. start the program (init processing)
                    2. check if theres an old zip on the machine (checkRemoveOldZip())
                    3. do your download...

                    HISE Development for hire.
                    www.channelrobot.com

                    DanHD 1 Reply Last reply Reply Quote 0
                    • DanHD
                      DanH @Lindon
                      last edited by

                      @Lindon because there's one button which opens the dialogue for the user to select the location and then executes the download. So I'm trying to shoehorn the check into there. I can't do the check until the dir is defined as you pointed out but in this case its also the same function as the download...

                      DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                      https://dhplugins.com/ | https://dcbreaks.com/
                      London, UK

                      LindonL 1 Reply Last reply Reply Quote 0
                      • LindonL
                        Lindon @DanH
                        last edited by

                        @DanH - but you always want to delete old zips dont you?

                        HISE Development for hire.
                        www.channelrobot.com

                        DanHD 1 Reply Last reply Reply Quote 0
                        • DanHD
                          DanH @Lindon
                          last edited by

                          @Lindon yes but there's no way of knowing where they are until dir is defined. which is the same function as the download. Can you think of a way of separating these? I'm trying with a timer.... ...... ok hang on... just exported it and the behaviour is different to within Hise and I thiiiink it might work with what I posted above after all... which would be nice!

                          Thanks for your help :)

                          DHPlugins / DC Breaks | Artist / Producer / DJ / Developer
                          https://dhplugins.com/ | https://dcbreaks.com/
                          London, UK

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post

                          50

                          Online

                          1.7k

                          Users

                          11.7k

                          Topics

                          101.8k

                          Posts