Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

Fix #372 - Do not create conflicted copies if the client has a newer version of a file, and upstream that file #443

Merged
merged 2 commits into from
Oct 29, 2014

Conversation

gideonthomas
Copy link
Contributor

No description provided.

@@ -117,6 +118,9 @@ function createFS(options) {
var autoSync;
var pathCache;

// Path needed to be upstreamed during a downstream sync
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand this comment. I think it needs more context. It seems odd, on its face, to be talking about a path to be upstreamed during a downstream.

upstreamPath = resolvePath(needUpstream);
requestSync(upstreamPath);
} else {
upstreamPath = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: it looks like needUpstream and upstreamPath are in play at the same time as one another; could we just use upstreamPath to indicate that we need to upstream, and not have a second variable? If not possible, fine. Just wondering. The fewer variables and states to manage, the fewer bugs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/mozilla/makedrive/pull/443/files#diff-c3ede5b5250ec9a7181630da3090839aR211 uses it to manage error states...its kinda equivalent to pathCache in a way

@humphd
Copy link
Contributor

humphd commented Oct 21, 2014

I think code looks pretty reasonable, and I've done one pass through it. I think the proof is in the testing, though, so it would be good to see what @alicoding sees when running this patch with Mobile Webmaker.

This was a pretty big change, thanks for getting it done so quickly.

@gideonthomas
Copy link
Contributor Author

@alicoding would you be able to test this?

@alicoding
Copy link
Collaborator

File created before sync happen never get synced when connected again.

STR:

  1. Connect to MakeDrive
  2. Create file /path/to/file.txt
  3. Write something to the file Hello World
  4. Quit the browser before sync will happen
  5. Reopen the browser and connect to MakeDrive again
  6. Check /p/path/to/file.txt (Expected to see the file, but result we don't see it)
  7. Try to MakeDrive.fs().sync.request() just to see if we can force sync the file
  8. Checked again and no sync happened.

@humphd
Copy link
Contributor

humphd commented Oct 21, 2014

Why do you expect to see the file if you haven't synced yet? How could the server have a file that is only local, and has never been synced?

@alicoding
Copy link
Collaborator

@humphd I actually did MakeDrive.fs().sync.request(); and expected to see the file, but I'm not really sure if this is just how Nimble was setup and no file is being sync after I did that?

@humphd
Copy link
Contributor

humphd commented Oct 21, 2014

If you did MakeDrive.fs().sync.request() then you did do a sync, right? You say above then you never synced. Can you clarify exactly what you are doing. Your steps are not detailed enough.

@alicoding
Copy link
Collaborator

@humphd Sorry, I meant after my second reconnect I was trying to see why my local file is not being sync and even I have tried MakeDrive.fs().sync.request() and it doesn't seem like syncing it up to the upstream.

@gideonthomas
Copy link
Contributor Author

@alicoding I might need more info because I tried to reproduce the error in the demo and am not getting it

@gideonthomas
Copy link
Contributor Author

@humphd so @alicoding and I were discussing today about this issue that he found. It doesn't really seem directly related to my patch but it needs to be fixed (filed in #450).

The thing is, triggering a sync relies on fs.pathToSync which is undefined until changes are made to files. So, when Ali makes the change to the file, it gets recorded in pathToSync, but he closes the tab (disconnects) before the sync can happen. Consequently, fs and in turn fs.pathToSync goes out of scope and gets destroyed. So when Ali opens a new tab again, and calls sync.request(), pathToSync is obviously undefined as it is initialized with a new fs instance and thus a sync cannot happen UNTIL Ali makes a change to that file (which causes pathToSync to update) and trigger a sync.

One way we thought about fixing this is by creating the /etc directory to hold stuff that we want to persist about the fs between sessions e.g. pathToSync. However, we need to discuss this and come back to it later.

More importantly, would you be able to quickly review my code again when you get time so that we can land this code before the milestone ends?

pathCache = fs.pathToSync;
fs.pathToSync = null;
manager.syncPath(pathCache);
// We do not expose a prototype that allows
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this comment mean? That we need to do this in the future? If so, file a bug. If not, clarify the comment.

// If the file was modified before the
// diffNode's modified time, the file is outdated
// and needs to be patched
if(stats.mtime <= diffNode.modified) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder how we should deal with the NOMTIME flag being set for the filesystem, see https://github.com/filerjs/filer#filerfilesystemoptions-callback-constructor. It would break your expectations here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can address it in #447

@humphd
Copy link
Contributor

humphd commented Oct 25, 2014

A few comments. Once those are fixed, make sure travis passes, and get @alicoding to do a functional test with Mobile Webmaker. I don't need to review this again unless it changes a lot.

@gideonthomas
Copy link
Contributor Author

@alicoding would you be able to test this on mobile webmaker?

@alicoding
Copy link
Collaborator

r+!

@gideonthomas gideonthomas merged commit f64388e into mozilla:master Oct 29, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants