Skip to content

Commit

Permalink
core/local/analysis: Don't confuse addDir(a)+addDir(a) with ident. re…
Browse files Browse the repository at this point in the history
…naming (#1201)
  • Loading branch information
sebn authored and aenario committed Oct 12, 2018
1 parent efcba0b commit 479298d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/local/analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function analyseEvents (events /*: LocalEvent[] */, pendingChanges /*: LocalChan
break
}
const addChange /*: ?LocalDirAddition */ = localChange.maybePutFolder(getChangeByInode(e))
if (addChange) {
if (addChange && addChange.path !== e.path) {
changeFound(localChange.dirRenamingCaseOnlyFromAddAdd(addChange, e))
break
}
Expand Down
22 changes: 22 additions & 0 deletions test/unit/local/analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,28 @@ describe('core/local/analysis', function () {
should(pendingChanges).deepEqual([])
})

it('identifies 2 successive addDir on same path/ino but different stats as DirAddition(foo/) with the last stats', () => {
const path = 'foo'
const ino = 1
const old /*: Metadata */ = metadataBuilders.dir().path(path).ino(ino).build()
const stats1 = {ino, size: 64}
const stats2 = {ino, size: 1312}
const events /*: LocalEvent[] */ = [
{type: 'addDir', path, stats: stats1, old},
{type: 'addDir', path, stats: stats2, old}
]
const pendingChanges = []

should(analysis(events, pendingChanges)).deepEqual([{
sideName,
type: 'DirAddition',
path,
ino,
stats: stats2,
old
}])
})

it('identifies addDir({path: foo, ino: 1}) + addDir({path: FOO, ino: 1}) as DirMove(foo, FOO)', () => {
const old /*: Metadata */ = metadataBuilders.dir().path('foo').ino(1).build()
const stats = {ino: 1}
Expand Down

0 comments on commit 479298d

Please sign in to comment.