diff options
author | Alberto Ruiz <alberto.ruiz@codethink.co.uk> | 2011-10-04 02:02:56 +0100 |
---|---|---|
committer | Alberto Ruiz <alberto.ruiz@codethink.co.uk> | 2011-10-04 02:02:56 +0100 |
commit | c752738666242cbd1bea413331312e784d0473d2 (patch) | |
tree | 666e2016c03eed2cbc2f8f104f34e1fe0eaf9053 | |
parent | fe006e0138cb83e2a25a9e11acec46f8615893d9 (diff) | |
download | tbdiff-c752738666242cbd1bea413331312e784d0473d2.tar.gz |
Fix directory difference command sequence
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | libtbd_create.c | 9 | ||||
-rw-r--r-- | libtbd_stat.c | 7 |
3 files changed, 15 insertions, 3 deletions
@@ -41,6 +41,8 @@ uninstall: rm -rf /usr/local/bin/$(DEPLOY) rm -rf /usr/local/bin/$(CREATE) +test: + cd tests && ./run_tests.sh && cd .. .PHONY: clean clean: rm -f $(DEPLOY) $(CREATE) *.o *.d diff --git a/libtbd_create.c b/libtbd_create.c index be5f913..a85a0bd 100644 --- a/libtbd_create.c +++ b/libtbd_create.c @@ -660,14 +660,19 @@ tbd_create_impl(FILE *stream, // Handle deletions. for(i = 0; i < a->size; i++) { + err = 0; + tbd_stat_t *_a = tbd_stat_entry(a, i); if(_a == NULL) return tbd_error(TBD_ERROR_UNABLE_TO_STAT_FILE); tbd_stat_t *_b = tbd_stat_entry_find(b, _a->name); - fprintf(stderr, "file delete %s\n", _a->name); - err = (_b != NULL ? 0 : tbd_create_cmd_entity_delete(stream, _a->name)); + + if (_b == NULL) + err = tbd_create_cmd_entity_delete(stream, _a->name); + tbd_stat_free(_b); tbd_stat_free(_a); + if(err != 0) return err; } diff --git a/libtbd_stat.c b/libtbd_stat.c index 905720b..006d2fc 100644 --- a/libtbd_stat.c +++ b/libtbd_stat.c @@ -181,15 +181,20 @@ tbd_stat_entry_find(tbd_stat_t *file, struct dirent *ds; for(ds = readdir(dp); ds != NULL; ds = readdir(dp)) { if(strcmp(ds->d_name, name) == 0) { - closedir (dp); char *spath = tbd_stat_subpath(file, ds->d_name); + if(spath == NULL) + { + closedir (dp); return NULL; + } + tbd_stat_t *ret = __tbd_stat(ds->d_name, (const char *)spath); free(spath); ret->parent = file; + closedir (dp); return ret; } } |