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

Bug #30

Open
dcircleinc opened this issue Sep 23, 2024 · 41 comments
Open

Bug #30

dcircleinc opened this issue Sep 23, 2024 · 41 comments
Labels
bug Something isn't working

Comments

@dcircleinc
Copy link

I get "Invalid procedure call or argument" in the following code:

in the code "syncDir = collSyncIDToDir(.syncID)" below:

#If Mac Then
    If collSyncIDToDir.Count > 0 Then 'Replace sandbox paths
        For i = 1 To m_providers.pCount
            With m_providers.arr(i)
                Dim syncDir As String: syncDir = collSyncIDToDir(.syncID)
                .mountPoint = Replace(.mountPoint, .baseMount, syncDir)
            End With
        Next i
    End If
#End If

MAC latest OS. Works on one mac, but not the other.
Reset OneDrive.

@dcircleinc dcircleinc added the bug Something isn't working label Sep 23, 2024
@cristianbuse
Copy link
Owner

Thanks @dcircleinc for raising this and the other issues. I will try to check this tomorrow on my Mac.

@dcircleinc
Copy link
Author

dcircleinc commented Sep 23, 2024 via email

@cristianbuse
Copy link
Owner

Thanks @dcircleinc for the detailed info!

I updated to the latest OneDrive version for Mac (the preview one) and I cannot recreate the issue. Can you please test Guido's version of GetLocalPath and see if that has the same issue on the other Mac?

@dcircleinc
Copy link
Author

dcircleinc commented Sep 25, 2024 via email

@dcircleinc
Copy link
Author

dcircleinc commented Sep 25, 2024 via email

@cristianbuse
Copy link
Owner

Maybe there’s a way to force excel to require asking for permissions again

I don't know how to do this but I don't think it's necessary. Once permission is granted the file can be accessed and if permission is denied then next time the macro tries to accesss the file then the Grant Access dialog pops-up anyway.

I though resetting OneDrive resolved it, but it was actually restarting the Mac

I moved a folder that was synced via a shortcut. Nothing I did updated the ini file under OneDrive settings. Until I restarted. This indeed seems to be a OneDrive issue and it makes sense why the code is not working - because it's reading obsolete information. And this was on Windows. On Mac is the same.

It almost feels that we would need to find a way to force update the settings files that OneDrive is using. Maybe there is a way to automate this but I would have to read the Microsoft documentation, if I can find the correct one and if even possible from VBA.

Thanks for now! I wiill leave this open until I find the time to delve into it properly.

@dcircleinc
Copy link
Author

dcircleinc commented Sep 30, 2024 via email

@cristianbuse
Copy link
Owner

Thanks @dcircleinc

I just pushed a new version. Can you please test it? If it still fails can you please provide me with the version of OneDrive where the code fails?

@dcircleinc
Copy link
Author

dcircleinc commented Oct 1, 2024 via email

@dcircleinc
Copy link
Author

dcircleinc commented Oct 1, 2024 via email

@dcircleinc
Copy link
Author

dcircleinc commented Oct 1, 2024 via email

@cristianbuse
Copy link
Owner

@dcircleinc

I don’t think the “.” should be there

Yes, it does. It refers to the m_providers.arr(i).syncID from the enclosing With block.

Could you please try the latest code? Just pushed a minor change.

@dcircleinc
Copy link
Author

dcircleinc commented Oct 1, 2024 via email

@cristianbuse
Copy link
Owner

When I reverted and removed the .syncID and set it to synciD ,it returns the path properly, but since that’s supposed to be there, I’m not sure how or why it works.

This is very interesting. It should not work. I need to update the CreateODDiagnosticsFile method with the extra information for sandboxing that is only relevant to Mac. I will let you know when I'm done so you can run it.

Thanks for all the feedback!

@cristianbuse
Copy link
Owner

@dcircleinc

Could you please update the latest version and run the CreateODDiagnosticsFile method? This will create a file with some useful information that can guide me in the right direction. Can you then share the file contents?

Many thanks!

@cristianbuse
Copy link
Owner

@dcircleinc

Thanks for the diagnostics data. I deleted the data because it was in issue #29.

It seems, the code cannot read the following:

  1. the main mount location - I would expect this to be something like /Users/ryan/Library/CloudStorage/OneDrive-Personal/
  2. the sync paths

Your configuration must be different than mine. I will look into this and let you know.

@dcircleinc
Copy link
Author

dcircleinc commented Oct 1, 2024 via email

@cristianbuse
Copy link
Owner

Thanks again for all the help so far. I still need some more info if possible.

In the 95bbe8e999b9a6af.ini file, the first line should be like library = .... I would need that line to see why the mount point is not being read. This file can be found at: /Users/ryan/Library/Application Support/OneDrive/settings/.

As for the sync IDs, there should be a file called .849C9593-D756-4E56-8D6E-42412F2A707B at: /Users/ryan/Library/CloudStorage/OneDrive-Personal/. You might need to CTRL+Shift+. from keyboard (Command+Shift+Dot). The contents of the file should look like this: {"guid" : "564ad8ab-4e36-4f3a-9eff-0ae1bb13a24d","version" : 1}. Is the file there and what is the content?

@dcircleinc
Copy link
Author

dcircleinc commented Oct 1, 2024 via email

@cristianbuse
Copy link
Owner

I can’t find this directory nor the .ini file. I searched for the .ini as well, no result

Maybe here: /Users/ryan/Library/Containers/com.microsoft.OneDrive-mac/Data/Library/Application Support/OneDrive/settings/

@dcircleinc
Copy link
Author

dcircleinc commented Oct 1, 2024 via email

@cristianbuse
Copy link
Owner

Try opening with TextEditor app. If it still does not open then please send me the file at [email protected]

Weird that the guid updated. The one starting with 6 looked wrong anyway.

@dcircleinc
Copy link
Author

dcircleinc commented Oct 1, 2024 via email

@dcircleinc
Copy link
Author

dcircleinc commented Oct 1, 2024 via email

@dcircleinc
Copy link
Author

dcircleinc commented Oct 2, 2024 via email

@cristianbuse
Copy link
Owner

Then onedrive had me sign in again, and it keeps saying now I have 2 of the same onedrive accounts running, and i’m in a loop.

OneDrive has probably updated on your computer(s) but it kept files in different places and now it's all "confused" about it.

Could you please use the latest version of this repo (did some changes last night) and re-run the ``CreateODDiagnosticsFile``` method? Thanks!

@dcircleinc
Copy link
Author

dcircleinc commented Oct 2, 2024 via email

@cristianbuse
Copy link
Owner

Ok, so the problem still lies with the Sync IDs and apparently for some reason the Main Mount is blank until you restart.

Hopefully last thing I ask, can you please put the below code into a new module, run the PrintSyncIDs method and let me know what got printed to the Immediate window?

Option Explicit

Sub PrintSyncIDs()
    Const syncIDFileName As String = ".849C9593-D756-4E56-8D6E-42412F2A707B"
    Dim collCloudDirs As Collection: Set collCloudDirs = GetODCloudDirs()
    Dim collFiles As New Collection
    Dim odCloudDir As Variant
    Dim arrPaths() As String
    Dim syncID As String
    Dim fileName As String
    Dim folderPath As String
    Dim i As Long
    '
    For Each odCloudDir In collCloudDirs
        collFiles.Add odCloudDir
        collFiles.Add odCloudDir & "/" & syncIDFileName
    Next odCloudDir
    arrPaths = CollectionToStrings(collFiles)
    If Not GrantAccessToMultipleFiles(arrPaths) Then Exit Sub
    '
    Set collFiles = New Collection
    For Each odCloudDir In collCloudDirs
        syncID = ReadSyncID(odCloudDir & "/" & syncIDFileName)
        If LenB(syncID) > 0 Then
            Debug.Print odCloudDir, syncID
        Else
            fileName = Dir(odCloudDir & "/", vbDirectory)
            Do While LenB(fileName) > 0
                folderPath = odCloudDir & "/" & fileName
                collFiles.Add folderPath
                collFiles.Add folderPath & "/" & syncIDFileName
                fileName = Dir
            Loop
        End If
    Next odCloudDir
    If collFiles.Count > 0 Then
        arrPaths = CollectionToStrings(collFiles)
        If Not GrantAccessToMultipleFiles(arrPaths) Then Exit Sub
        '
        For i = LBound(arrPaths) To UBound(arrPaths) Step 2
            syncID = ReadSyncID(arrPaths(i + 1))
            If LenB(syncID) > 0 Then Debug.Print arrPaths(i), syncID
        Next i
    End If
End Sub

Private Function GetODCloudDirs() As Collection
    Dim coll As New Collection
    Dim cloudPath As String:  cloudPath = GetCloudPath()
    Dim folderName As String: folderName = Dir(cloudPath, vbDirectory)
    '
    Do While LenB(folderName) > 0
        If folderName Like "OneDrive*" Then
            coll.Add BuildPath(cloudPath, folderName)
        End If
        folderName = Dir
    Loop
    Set GetODCloudDirs = coll
End Function
Private Function GetCloudPath() As String
    GetCloudPath = GetUserPath() & "Library/CloudStorage/"
End Function
Private Function GetUserPath() As String
    GetUserPath = "/Users/" & Environ$("USER") & "/"
End Function
Private Function CollectionToStrings(ByVal coll As Collection) As String()
    If coll.Count = 0 Then
        CollectionToStrings = Split(vbNullString)
        Exit Function
    End If
    '
    Dim res() As String: ReDim res(0 To coll.Count - 1)
    Dim i As Long
    Dim v As Variant
    '
    For Each v In coll
        res(i) = v
        i = i + 1
    Next v
    CollectionToStrings = res
End Function
Private Function ReadSyncID(ByRef syncFilePath As String) As String
    Dim b() As Byte:       ReadBytes syncFilePath, b
    Dim parts() As String: parts = Split(StrConv(b, vbUnicode), """guid"" : """)
    '
    If UBound(parts) < 1 Then Exit Function
    ReadSyncID = Left$(parts(1), InStr(1, parts(1), """") - 1)
End Function

@cristianbuse
Copy link
Owner

I forgot to mention, the code above must be placed in the same project as the LibFileTools module as it uses a few methods from it.

@dcircleinc
Copy link
Author

dcircleinc commented Oct 4, 2024 via email

@cristianbuse
Copy link
Owner

cristianbuse commented Oct 4, 2024

Still, It makes absolutely no sense that it works with syncID instead of .syncID. The former is the result of the last syncID = ReadSyncID(... that happened in the same method and should be already added to the collSyncIDToDir collection as a key.

I wish I was able to debug this myself. It's driving me nuts as I cannot replicate.

@dcircleinc
Copy link
Author

dcircleinc commented Oct 4, 2024 via email

@cristianbuse
Copy link
Owner

Hi Ryan,

Any updates on this? I've been a bit swamped in the last 2-3 weeks and had no chance to revisit. Thanks!

@dcircleinc
Copy link
Author

dcircleinc commented Oct 21, 2024 via email

@cristianbuse
Copy link
Owner

Was I supposed to send something else ?

No. But you mentioned that you are writing an alternative method and was wondering if while doing it, you stumbled across the answer of how the issue is happening.

I wrote a brute force method ....

Ok. I think I understand what you've done. Thanks!

I will think about this in the next few days and will let you know if any idea comes to mind.

@dcircleinc
Copy link
Author

dcircleinc commented Nov 5, 2024 via email

@dcircleinc
Copy link
Author

dcircleinc commented Nov 6, 2024 via email

@cristianbuse
Copy link
Owner

Thanks for the info Ryan!

I could look into forcefully terminate the OneDrive process via an API call and possibly restart it. I've done this many years ago but not sure how reliable it would be nowadays or if it's even allowed by modern antivirus software.

Before I even go down that rabbit hole, I assume you've already tried to set the rebuildCache argument to True when calling GetLocalPath / GetRemotePath? Thanks!

@dcircleinc
Copy link
Author

dcircleinc commented Nov 7, 2024 via email

@dcircleinc
Copy link
Author

dcircleinc commented Nov 7, 2024 via email

@cristianbuse
Copy link
Owner

cristianbuse commented Dec 12, 2024

Hi Ryan,

Was quite busy in the last few weeks with VB6 / VBA is slow to deallocate class instances that I completely forgot to mention that I did an update 2 weeks ago to this repo that makes rebuildcache redundant and basically useful just for testing purposes.

Would be good to hear from you if the problem still persists in this new version. Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants