Changeset 75


Ignore:
Timestamp:
07/16/09 03:49:56 (3 years ago)
Author:
dom
Message:

Fixed a bug in directory_watcher.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/directory_watcher.erl

    r60 r75  
    124124    report_lost (Fun, X), 
    125125    compare (Fun, Xs, []); 
     126compare (Fun, [X], [Y]) -> 
     127    report_lost (Fun, X), 
     128    {File, _} = Y, 
     129    report_found (Fun, File), 
     130    done; 
    126131compare (_, [], []) -> 
    127132    done. 
  • trunk/src/directory_watcher_test.erl

    r60 r75  
    1616-export ([change_from_file_to_directory/0]). 
    1717-export ([change_from_file_to_directory_when_recursive/0]). 
     18-export ([remove_and_add_in_same_check/0]). 
    1819 
    1920tests_from_empty () -> 
     
    6768    F = fun change_from_directory_to_file_when_recursive/2, 
    6869    ok = fixtures: use_tree (tree (), F). 
    69      
     70 
     71remove_and_add_in_same_check () ->     
     72    F = fun remove_and_add_in_same_check/2, 
     73    ok = fixtures: use_tree ([{file, "foo", "foo"}], F). 
     74 
    7075tree () -> 
    7176    Subsub = {directory, "subsubdir", 
     
    255260    ok. 
    256261 
     262remove_and_add_in_same_check (Root, _) -> 
     263    Watcher = spawn_link (directory_watcher, init_recursive, [Root, send_me ()]), 
     264    receive_all (), 
     265    [Foo, Bar] = [filename: join (Root, X) || X <- ["foo", "bar"]], 
     266    ok = file: delete (Foo), 
     267    ok = file: write_file (Bar, list_to_binary ("bar")), 
     268    Watcher ! check, 
     269    [{{file, ""}, Foo, lost}, 
     270     {{file, ""}, Bar, found}] = receive_all (), 
     271    ok. 
     272     
     273 
    257274send_me () -> 
    258275    Self = self (), 
Note: See TracChangeset for help on using the changeset viewer.