Question about upgrading an extension in extension warehouse

I have changed my input boxes by html dialogs in my extension. In order to update the extension into extension warehouse I have to create a new draft and change data. My question is… Can I add a prefix to my extension name folder like others extensions have? Will be a problem with the previous version because of the name of the functions that remains?
I don’t know if a user update the extension by extension admin sketchup first delete previously the last data although the name is not the same.

my change will be:

  • AddIFCQuantities.rb changes to rtches_AddIFCQuantities.rb
  • AddIFCQuantities folder changes to rtches_AddIFCQuantities
  • functions names remains

YES Please DO make this change. We have been asking that the registrar file and extension subfolder names be company/namespace prefixed like forever. (Since v8 or 2013 at least.)

No because of the name change, users will need to manually uninstall the old version via the Extension Manager.

The name of the file(s) does not affect the module names.

If you change (or added) a top level Rtches namespace module) … did you prefix function calls with the old module name or just self. ?

My previous code was Ok when the extension was aproved (as you say, with modules)

module Rtches
  module AddQuantities

That’s the reason why I said that if you don’t uninstall the previous version you will have same functions in both versions because there are no changes in functions.

The only changes are in Sketchup plugins folder. Name and folder name

Installing from the EW just unzips and copies files and folders into the Plugins folder. If there are old files with the same name, they will be overwritten. But if there are obsolete files or folders the EW install does not remove them. You have to add code to your extension that detects and removes them. I ran into this issue when I changed some of my extensions to encrypted and the old unencrypted Ruby files caused clashes.

I made a small update. Next update I’ll try to code something to delete old versions.
Thanks for the advice @slbaumgartner

Yes I also ran into this issue recently with @Aerilius’s Attribute Inspector because he changed the name of the registrar file and extension subfolder. I did not realize this and the extension did not work properly.

It took awhile, but once I saw two folders in the “Plugins” folder and manually deleted the old version, the new version began to act correctly.

@rtches Rafa, in this case your old version will be loading before the new version.

Hopefully the new version can redefine all the module objects etc. But probably not the UI objects if they are protected within an if clause.

The new version can look into the "Plugins" folder and see if the "AddIFCQuantities.rb" file exists. If so, then delete it and the old "AddIFCQuantities" folder using the File and Dir libraries.

Within your main extension submodule, put this and run it once upon startup:

    def check_for_old_version
      plugins   = File.dirname(__dir__)
      registrar = File.join(plugins,'AddIFCQuantities.rb')
      return unless File.exist?(registrar)
      # Does not remove loaded filepaths from $LOADED_FEATURES array
        # Delete the old extension registrar file:
        # Delete the old extension subfolder(s):
        sub = File.basename(registrar,'.rb')
        dir = File.join(plugins,sub)
        require 'fileutils'
        FileUtils.remove_dir(dir,true) if Dir.exist?(dir)
        # If it is unsafe to run with both versions loaded:
          "Old AddIFCQuantities extension removed.\n\nPlease restart SketchUp!"
      rescue => error
        puts error.inspect
    end ### check_for_old_version

Thanks @DanRathbun! I’ll Add the code in the next version.
Your help is always excellent.!

1 Like

Make sure to test. I didn’t as I do not have either version of your extension.

The update logic will remove the existing root RB file and it’s accompanying support folder before unpacking the new version.

Yes, now, but at one time it was bugged as Steve describes.
I cannot find in the release notes a mention of when it was fixed.

In the scenario described by the topic opener, the special case is that the old version did not have the same registrar and folder name as the newer version. So either a manual delete or the newer version must sniff out and delete any old version.

Again …

… I had to do a manual delete of the old version files.