cristianbuse / VBA-FileTools

Useful methods for interacting with the file system
MIT License
81 stars 23 forks source link

Error in 'AddPersonalProviders' #21

Closed cristianbuse closed 6 months ago

cristianbuse commented 6 months ago

We started getting another error one one computer. Onedrive is running.

The error is on this line:

    i = InStr(1, lineText, "_Path", vbTextCompare)

            If i > 0 Then

                relPath = Mid$(lineText, i + 8)

                folderID = Left$(lineText, i - 1)

                If cDirs Is Nothing Then Set cDirs = GetODDirs(aInfo)

                With m_providers.arr(AddProvider())

                    .webPath = mainURL & cID & "/" & relPath & "/"

                    .mountPoint = BuildPath(mainMount, cDirs(folderID) & "/")

                    .baseMount = mainMount

                    .syncID = syncID

                End With

            End If

I just added "on error resume next" above that line and the code executes on this computer, and seems to still find the path. Just not sure what other affect that may have. It has worked on this computer until today.

Ryan Taliercio

---- On Tue, 06 Jun 2023 20:51:52 -0400 Ryan Taliercio @.***> wrote ---

Unfortunately, I got the same error when I changed that line. On the other computers, the code no longer executed like it previously did and didn't find the folder. I reverted back to the original code, and it works on the other computers, but gives the same error on the one in question.  

Ryan Taliercio

---- On Tue, 06 Jun 2023 13:16:14 -0400 Cristian Buse @.***> wrote ---

Thanks https://github.com/dcircleinc ,

I can see what the problem is. The folder count (coll count) cannot possibly be just 1 as surely you have more than 1 folder in your Personal OneDrive. What this means is that the algorithm in the GetODDirs method cannot find the folders as most likely you have a different byte configuration for the dat file. The method reads all the bytes and then searches for folder headers (hex x02 followed by x01000000).

Could you please change https://github.com/cristianbuse/VBA-FileTools/blob/feb2a11a917616b888e275ce385fec0e456c4f5a/src/LibFileTools.bas#L2288:

For stepSize = 16 To 8 Step -8

to:

For stepSize = 8 To 8 Step -8

and try again to see if it works. Thanks!

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/15#issuecomment-1579159594, or https://github.com/notifications/unsubscribe-auth/AAHBDF4RQH2AYFCJZZVQ5HDXJ5QV5ANCNFSM6AAAAAAY3M4NDU. You are receiving this because you were mentioned.

Originally posted by @dcircleinc in https://github.com/cristianbuse/VBA-FileTools/issues/15#issuecomment-1986882142

cristianbuse commented 6 months ago

Hi @dcircleinc

Since this is related to a Personal OneDrive, I wonder if some of the files from the 'old' user got preserved and are now interfering with the files for the 'new' user.

Can you please confirm the following?

1) There is a single 'Personal' folder here: %LocalAppData%\Microsoft\OneDrive\settings 2) There is a single 'SyncEngineDatabase.db' file in the 'Personal' folder 3) There is a single 'global.ini' file in the 'Personal' folder 4) The 'cid = xxxxx' line if the 'global.ini' file matches a file named 'xxxxx.ini' in the 'Personal' folder where xxxxx is your personal one drive id

Many thanks!

dcircleinc commented 6 months ago

See below answers

Ryan Taliercio

---- On Mon, 11 Mar 2024 05:36:22 -0400 Cristian Buse @.***> wrote ---

Hi https://github.com/dcircleinc

Since this is related to a Personal OneDrive, I wonder if some of the files from the 'old' user got preserved and are now interfering with the files for the 'new' user.

Can you please confirm the following?

There is a single 'Personal' folder here: %LocalAppData%\Microsoft\OneDrive\settings

There is a single "Personal" folder AND a Business1 Folder. There is a single 'SyncEngineDatabase.db' file in the folder above

There is a single syncEngineDatbase.db file, and a SyncEngineDatabase.db-shm and db-wal file There is a single 'global.ini' file in the above folder

Yes one global.ini The 'cid = xxxxx' line if the 'global.ini' file matches a file named 'xxxxx.ini' in the above folder where xxxxx is your personal one drive id

Yes this matches Many thanks!

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/21#issuecomment-1987982030, or https://github.com/notifications/unsubscribe-auth/AAHBDF7WBRXF3PGLYARE563YXV3JNAVCNFSM6AAAAABEP5V3KOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBXHE4DEMBTGA. You are receiving this because you were mentioned.

cristianbuse commented 6 months ago

Thanks @dcircleinc

I will try something tomorrow and let you know. In the meanwhile were you able to try Guido's code and see if his is throwing an error?

dcircleinc commented 6 months ago
        I have toadd the other code from Guido after hours so I will let you Know when I try it. Your code is working now with the “on error resume next” I added but I hate doing that  … so somehow it still gets the correct path even though it tries to call the statement that causes the error. It must get the path properly at another point And do you have a way to donate to your project?Ryan Taliercio    ---- On Mon, 11 Mar 2024 11:22:30 -0400  ***@***.******@***.***> wrote ----  

Thanks @dcircleinc I will try something tomorrow and let you know. In the meanwhile were you able to try Guido's code and see if his is throwing an error?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

dcircleinc commented 6 months ago

So for shits and giggles I checked Guido's and was able to confirm the CID returned in the code (near the errored out code) matched what was in thef folder. I ran the REset Onedrive command in windows to start it over, it resynched, and then the errors disappeared in both versions of the code. I now have yours back and have removed the on error resume next.

Does this help clarify for you what could possibly cause the error?

Ryan Taliercio

---- On Mon, 11 Mar 2024 11:22:30 -0400 Cristian Buse @.***> wrote ---

Thanks https://github.com/dcircleinc

I will try something tomorrow and let you know. In the meanwhile were you able to try Guido's code and see if his is throwing an error?

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/21#issuecomment-1988701086, or https://github.com/notifications/unsubscribe-auth/AAHBDF2SGRH76FC5MBHFFQ3YXXD3NAVCNFSM6AAAAABEP5V3KOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBYG4YDCMBYGY. You are receiving this because you were mentioned.

dcircleinc commented 6 months ago

OK So I put in Guido's code instead and I also get an error in orange:

For Each line In Split(b, vbNewLine)

                If line Like "_BaseUri = " And cid = vbNullString Then

                    cid = LCase$(Mid$(line, InStrRev(line, "/", , 0) + 1, _

                       InStrRev(line, "!", , 0) - InStrRev(line, "/", , 0) - 1))

                    folderID = Left$(line, InStr(1, line, "_", 0) - 1)

                ElseIf cid <> vbNullString Then

                    locToWebColl.Add VBA.Array(locRoot & ps & odFolders( _

                                     folderID)(1), webRoot & "/" & cid & "/" & _

                                     Mid$(line, Len(folderID) + 9), email, _

                                     syncID, syncFind, dirName), _

                                Key:=locRoot & ps & odFolders(folderID)(1)

                    cid = vbNullString: folderID = vbNullString

                End If

            Next line

        End If

NextFolder:

Ryan Taliercio

---- On Mon, 11 Mar 2024 11:22:30 -0400 Cristian Buse @.***> wrote ---

Thanks https://github.com/dcircleinc

I will try something tomorrow and let you know. In the meanwhile were you able to try Guido's code and see if his is throwing an error?

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/21#issuecomment-1988701086, or https://github.com/notifications/unsubscribe-auth/AAHBDF2SGRH76FC5MBHFFQ3YXXD3NAVCNFSM6AAAAABEP5V3KOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSOBYG4YDCMBYGY. You are receiving this because you were mentioned.

cristianbuse commented 6 months ago

Thank you @dcircleinc ,

So, the problem was solved by Resetting OneDrive? I only ask because I am not sure I am seeing your messages in order because you are replying from email.

dcircleinc commented 6 months ago
        Yes sorry they got sent out in the wrong order. Resetting one drive solved the error in BOTH your version and Guido’s. Signing out and in didn’t change anything, but the resetting did (though the CID remained the same). So there seems to be something when switching the onedrive personal to another account/login, but reusing the original onedrive path in windows. Ryan Taliercio    ---- On Mon, 11 Mar 2024 19:32:43 -0400  ***@***.******@***.***> wrote ----  

Thank you @dcircleinc , So, the problem was solved by Resetting OneDrive? I only ask because I am not sure I am seeing your messages in order because you are replying from email.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>

cristianbuse commented 6 months ago

Many thanks @dcircleinc !

I will keep this issue open until I have some time to try to replicate the issue and see if there is any change that would improve the code and cover this issue.

My guess is that there isn't much to do since it seems that without Reset the files are somewhat corrupted and unreliable and adding On Error Resume Next could be bad i.e. the cure is worse than the disease.

cristianbuse commented 6 months ago

Hi @dcircleinc ,

My last commit 191b798d02b67f9442cb02c566a205ccc5b37191 should fix the issue you raised. Many thanks again for your feedback! This is very helpful and it will serve many others.

To answer your previous question - I have enabled GitHub Sponsors so there is a 'Sponsor' button on the main repo page. I must say that I only enabled sponsorship in response to your question. You were the 3rd person that has asked this from me and I felt that it's time to enable. I must let you know that I provide all these work for free and I never had the intention to monetize this. So, please do not feel obligated in any way to donate - for me a simple 'thank you' is more than I ever wanted.

dcircleinc commented 4 months ago

Here's another issue I came across today, just appeared out of nowhere again. This was from the libFileTools version from around March 22. I even reset OneDrive and that didn't fix it. This happened to be on a Windows 11 (ARM) machine running in a VM, but this has always worked until today. I don't think the error appeared on the MAC.

I saw there was a newer version, so I put that in, and it seemed to fix the problem. Was this something that was addressed and fixed in this newest version? Could it be related to the VM setup (which did previously work)? Curious if there's some code I should put it just in case the error comes up again in the future, as a failsafe. When the user "ends" the macro in order to exit the error, they get stuck in Excel, as this function is called onBeforeClose, and they wind up unable to close the file.

Ryan Taliercio

---- On Fri, 22 Mar 2024 08:37:47 -0400 Cristian Buse @.***> wrote ---

Hi https://github.com/dcircleinc ,

My last commit https://github.com/cristianbuse/VBA-FileTools/commit/191b798d02b67f9442cb02c566a205ccc5b37191 should fix the issue you raised. Many thanks again for your feedback! This is very helpful and it will serve many others.

To answer your previous question - I have enabled GitHub Sponsors so there is a 'Sponsor' button on the main repo page. I must say that I only enabled sponsorship in response to your question. You were the 3rd person that has asked this from me and I felt that it's time to enable. I must let you know that I provide all these work for free and I never had the intention to monetize this. So, please do not feel obligated in any way to donate - for me a simple 'thank you' is more than I ever wanted.

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/21#issuecomment-2015002678, or https://github.com/notifications/unsubscribe-auth/AAHBDF5DGABGQSVO2INCT43YZQQZXAVCNFSM6AAAAABEP5V3KOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMJVGAYDENRXHA. You are receiving this because you were mentioned.

cristianbuse commented 4 months ago

Hi @dcircleinc ,

Indeed I pushed a new way of parsing the SQLite files just 2 weeks ago. The newest OneDrive version is using a newer version of SQLite which uses different binary headings. Instead of accounting all the posible headings, I changed the way I parse the files. The new way is more stable and will require less maintenance from my end.

I would say that the chance of an unexpected error has dropped significantly with the latest update but there's no guarantee that Microsoft won't change something substantial with the next release.

So, if you really want to avoid user issues, I siuggest you place error handling directly in the onBeforeClose event.

dcircleinc commented 2 months ago

Getting a new error on windows computers:

For Each lineText In Split(groupText, vbNewLine)

        If InStr(1, lineText, "_BaseUri", vbTextCompare) > 0 Then

            cID = LCase$(Mid$(lineText, InStrRev(lineText, "/") + 1))

            i = InStr(1, cID, "!")

            If i > 0 Then cID = Left$(cID, i - 1)

        Else

            i = InStr(1, lineText, "_Path", vbTextCompare)

            If i > 0 Then

                relPath = Mid$(lineText, i + 8)

                folderID = Left$(lineText, i - 1)

                If oDirs.dirCount = 0 Then ReadODDirs aInfo, oDirs

                With m_providers.arr(AddProvider())

                    .webPath = mainURL & cID & "/" & relPath & "/"

               relPath = oDirs.arrDirs(oDirs.idToIndex(folderID)).dirName

                    .mountPoint = BuildPath(mainMount, relPath & "/")

                    .baseMount = mainMount

                    .syncID = syncID

                End With

            End If

        End If

    Next lineText

End Sub

Runtime error "5" in "relPath" line.

---- On Wed, 08 May 2024 04:30:02 -0400 Cristian Buse @.***> wrote ---

Hi https://github.com/dcircleinc ,

Indeed I pushed a new way of parsing the SQLite files just 2 weeks ago. The newest OneDrive version is using a newer version of SQLite which uses different binary headings. Instead of accounting all the posible headings, I changed the way I parse the files. The new way is more stable and will require less maintenance from our end.

I would say that the chance of an unexpected error has dropped significantly with the latest update but there's no guarantee that Microsoft won't change something substantial with the next release.

So, if you really want to avoid user issues, I siuggest you place error handling directly in the onBeforeClose event.

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/21#issuecomment-2100042072, or https://github.com/notifications/unsubscribe-auth/AAHBDF7L345GO3MUDK3UIIDZBHPAVAVCNFSM6AAAAABEP5V3KOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBQGA2DEMBXGI. You are receiving this because you were mentioned.

cristianbuse commented 2 months ago

@dcircleinc

Are you using the latest version? If yes, can you run the CreateODDiagnosticsFile and share the text file with me?

Thanks!

dcircleinc commented 2 months ago

Just installed this, it was happening on 2 of 4 computers, until I installed the new version. I should have checked that first, I apologize.

I wondered if it was something to do with the issues onedrive has been having with shortcuts showing up instead of direct links to files.

---- On Thu, 04 Jul 2024 08:22:02 -0400 Cristian Buse @.***> wrote ---

https://github.com/dcircleinc

Are you using the latest version? If yes, can you run the CreateODDiagnosticsFile and share the text file with me? Thanks!

— Reply to this email directly, https://github.com/cristianbuse/VBA-FileTools/issues/21#issuecomment-2208843214, or https://github.com/notifications/unsubscribe-auth/AAHBDF5Y3KOOTMKTF57C4HLZKU46VAVCNFSM6AAAAABEP5V3KOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBYHA2DGMRRGQ. You are receiving this because you were mentioned.

cristianbuse commented 2 months ago

Great, thanks for letting me know.

cristianbuse commented 2 months ago

I wondered if it was something to do with the issues onedrive has been having with shortcuts showing up instead of direct links to files.

There have been some recent OneDrive updates, one of them related to SqLite db files - some of the syncronized Sharepoint/OneDrive folders now have a slightly different byte signature in the db file.