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

Add or Remove files directly in Dropbox does not update the list displayed on 'Open file from Dropbox' Window #88

Open
glandre opened this issue Mar 21, 2016 · 5 comments

Comments

@glandre
Copy link
Collaborator

glandre commented Mar 21, 2016

Repro steps:

  • Upload a file to Dropbox via OpenLatexStudio
  • Close OpenLatexStudio
  • Upload a file to Dropbox directly via Dropbox
  • Open OpenLatexStudio
  • Trigger Open from dropbox
  • Only the first file is available
  • Notice that after creating another file and uploading it to Dropbox (via OLS) the list is updated and all three files appears

Ideally, the list should always be retrieved when 'Open from Dropbox' is trigged.

@sebbrudzinski
Copy link
Owner

@glandre Did the file you uploaded had the ".tex" extension? We currently only display files from Dropbox that have the ".tex" extenstion.

@glandre
Copy link
Collaborator Author

glandre commented Mar 28, 2016

Yes, they were tex files. Since I've been working on Dropbox connection feature, I was intending to solve this problem before. However, I was working on another feature, so I decided to document it to not forget it.

Now that I've finished my previous task, I will work on it, OK?
I'll test on Windows to see if it is a Linux only behavior, and I will also investigate the cause of this problem.

glandre added a commit that referenced this issue Mar 28, 2016
@glandre
Copy link
Collaborator Author

glandre commented Mar 28, 2016

Hi @sebbrudzinski,
I did several tests here (only on Linux for now), and in fact it happens... In order to make sure, I followed the steps bellow:

  • I let the Dropbox Webpage opened;
  • I opened a file from Dropbox via OLS (all tex files were there);
  • I open my dropbox directory and added a new tex file;
  • I went to Dropbox Webpage and waited for the file to appear;
  • After the file appeared in the webpage I went to OLS and triggered "Open from Dropbox";
  • The file is not listed;
  • Than I waited for 3 minutes, closed the OLS, opened it again, and triggered again "Open from Dropbox", the file still wasn't there...

Debugging the code I noticed that the files are searched by searchFileAndFolderNames method. So I did some research and I found out the method getDelta. The specification says that it "... lets you efficiently keep up with the latest state of the files and folders" (https://dropbox.github.io/dropbox-sdk-java/api-docs/v1.7.x/com/dropbox/core/DbxClient.html#getDelta(java.lang.String)).

In fact, with this method the problem was solved. I replaced the first stretch bellow with the second:

  • First Stretch (problem):
        try {
            for (DbxEntry entry : client.searchFileAndFolderNames("/", ".tex")) {
                dbxEntries.add(new DbxEntryDto(entry));
            } 
        } catch (DbxException ex) {
            DbxUtil.showDbxAccessDeniedPrompt();
            return; //No point continuing
        }
  • Second Stretch (solution):
        String cursor = "";
        try {
            DbxDelta delta = client.getDelta(cursor);
            for (Object entryObj : delta.entries) {
                DbxDelta.Entry<DbxEntry> entry = (DbxDelta.Entry<DbxEntry>)entryObj;

                if (entry.metadata.name.endsWith(".tex")) {
                    dbxEntries.add(new DbxEntryDto(entry.metadata));
                }
            }
        } catch (DbxException ex) {
            DbxUtil.showDbxAccessDeniedPrompt();
            return; //No point continuing
        }

I will read a bit more, because, I still need to understand better the behavior of this method (getDelta). It requires this cursor parameter, so it seems to me that when there are a lot of files it retrieves the information in blocks.

In addition to that, I will set up a Windows Environment to test if it is just a Linux behavior or not.

@glandre
Copy link
Collaborator Author

glandre commented Mar 28, 2016

Oops! I tested on Windows the first time with my new code...
Now, on Windows, I've just executed the same steps I mentioned, and the problem happens too.

So it happens on both Linux and Windows... Probably the searchFileAndFolderNames uses some kind of cache...

@sebbrudzinski
Copy link
Owner

This is strange behaviour indeed, I've tested it a while ago and it worked fine for me. The reason we use searchFileAndFolder names is to not fetch all the files from the Dropbox acc (which is usually a lot and would use a lot of resources). For the reproduction sake. What is the file name that you are uploading to Dropbox? Also, what is the path? (or how deep is the file placed)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants