GeodatabaseSyncTask unregisterGeodatabase

628
3
07-24-2020 01:19 PM
MKa
by
Occasional Contributor III

I can seem to get the unregisterGeodatabase to work?  I have about 5 features services that I take offline.  I only sync one of the geodatabases, which also automatically unregisters it (it appears).  The other 4 I am attempting to unregister in code and it doesn't seem to work?

GeodatabaseSyncTask {
        id: geodatabaseSyncTask
        url: "https://mypath/FeatureServer"
        }


function unRegisterGeoDatabases() {
        try {
            while(GDBList.length > 0) {
                var gdb = aGDBList.pop()
                if (gdb)
                {
                    geodatabaseSyncTask.unregisterGeodatabase(gdb);
                }
            }
        } catch (err) {
            console.log("*****************ERROR FAIL****************");
            console.log("SurveyApp.qml - ERROR unRegisterGeoDatabases :", err);
            console.log("*******************************************");
        }
    }

//Called after the sync?  Do I need to do something like sync?
unRegisterGeoDatabases()

0 Kudos
3 Replies
MKa
by
Occasional Contributor III

to solve part of this I change the sync model per layer and only create replicas that I will later sync.  However, when cleaning up, is there a way to detect when the replica has been unregistered so that I can then delete the folder off the machine?


unRegisterGeoDatabases()
//I think this fails because the above unregister has the folder locked.
deleteMMPKFolders()
0 Kudos
MKa
by
Occasional Contributor III

The actual cause of me not being able to delete my MMPK folder after delete was because I had one of the gdbs held in memory.  I thought it was from the unregister task from above, but it was actually a variable that pointed to the GDB in my sync task.  After my sync task was complete, I cleared the variable and was able to delete the entire MMPK folder.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Couple of thoughts with this:

1) The QML API will only allow you to have one task in progress at a time. If you connect to the errorChanged signal on the task, I imagine you might see something like "There is a unregisterGeodatabase operation currently in progress."  "Please try again after the current operation completes.";. You will need to queue these tasks up and execute once the previous one was complete.

2) You mention "I only sync one of the geodatabases". If this is the case, could you try setting the GenerateGeodatabaseParameters.syncModel to Enums.SyncModelNone for the gdbs you don't want to sync. This will avoid you having to unregister them at all

0 Kudos