projects
/
feisty_meow.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
5fcd199
)
noisy logging turned on to help look for bug in directory tree.
author
root
<root@mail.koeritz.com>
Thu, 21 Jun 2012 18:21:40 +0000
(14:21 -0400)
committer
root
<root@mail.koeritz.com>
Thu, 21 Jun 2012 18:21:40 +0000
(14:21 -0400)
nucleus/library/filesystem/directory.cpp
patch
|
blob
|
history
nucleus/library/filesystem/directory_tree.cpp
patch
|
blob
|
history
nucleus/library/filesystem/filename.cpp
patch
|
blob
|
history
nucleus/library/filesystem/filename.h
patch
|
blob
|
history
octopi/library/tentacles/file_transfer_tentacle.cpp
patch
|
blob
|
history
octopi/library/tentacles/recursive_file_copy.cpp
patch
|
blob
|
history
diff --git
a/nucleus/library/filesystem/directory.cpp
b/nucleus/library/filesystem/directory.cpp
index e4e3adcdb92ed7bef3e23995145ddcc7d4cffd63..a122d577fd15edec2474762c03528d0ba655954f 100644
(file)
--- a/
nucleus/library/filesystem/directory.cpp
+++ b/
nucleus/library/filesystem/directory.cpp
@@
-161,15
+161,20
@@
bool directory::rescan()
if (!strcmp(filename_transcoded.s(), par_dir.s())) continue;
#ifdef UNICODE
if (!strcmp(filename_transcoded.s(), par_dir.s())) continue;
#ifdef UNICODE
-/
/
temp
+/
*
temp
to_unicode_persist(fudgemart, filename_transcoded);
if (memcmp((wchar_t*)fudgemart, wfd.cFileName, wcslen(wfd.cFileName)*2))
printf("failed to compare the string before and after transcoding\n");
to_unicode_persist(fudgemart, filename_transcoded);
if (memcmp((wchar_t*)fudgemart, wfd.cFileName, wcslen(wfd.cFileName)*2))
printf("failed to compare the string before and after transcoding\n");
+*/
#endif
//wprintf(to_unicode_temp("file is %ls\n"), (wchar_t*)to_unicode_temp(filename_transcoded));
filename temp_name(*_path, filename_transcoded.s());
#endif
//wprintf(to_unicode_temp("file is %ls\n"), (wchar_t*)to_unicode_temp(filename_transcoded));
filename temp_name(*_path, filename_transcoded.s());
+ if (!temp_name.is_normal()) {
+ LOG(astring("skipping abnormal file: ") + temp_name);
+ continue; // cannot be adding goofy named pipes etc; cannot manage those.
+ }
// add this to the appropriate list.
if (temp_name.is_directory()) {
// add this to the appropriate list.
if (temp_name.is_directory()) {
diff --git
a/nucleus/library/filesystem/directory_tree.cpp
b/nucleus/library/filesystem/directory_tree.cpp
index 77ea9472c7f518e9a3bd4c161399971d209213f5..2f267f9b6a8ca6993c13c653eec5b7b004555778 100644
(file)
--- a/
nucleus/library/filesystem/directory_tree.cpp
+++ b/
nucleus/library/filesystem/directory_tree.cpp
@@
-32,7
+32,7
@@
using namespace structures;
using namespace nodes;
using namespace textual;
using namespace nodes;
using namespace textual;
-
//
#define DEBUG_DIRECTORY_TREE
+#define DEBUG_DIRECTORY_TREE
// uncomment for noisier version.
#undef LOG
// uncomment for noisier version.
#undef LOG
@@
-187,6
+187,10
@@
void directory_tree::traverse(const astring &path, const char *pattern,
#ifdef DEBUG_DIRECTORY_TREE
LOG(astring("seeking path: ") + new_path);
#endif
#ifdef DEBUG_DIRECTORY_TREE
LOG(astring("seeking path: ") + new_path);
#endif
+ if (!filename(new_path).is_normal()) {
+LOG(astring("bailing on weird dir: ") + new_path);
+ continue; // only regular directories please.
+ }
for (int q = 0; q < add_to.branches(); q++) {
filename_tree *curr_kid = (filename_tree *)add_to.branch(q);
#ifdef DEBUG_DIRECTORY_TREE
for (int q = 0; q < add_to.branches(); q++) {
filename_tree *curr_kid = (filename_tree *)add_to.branch(q);
#ifdef DEBUG_DIRECTORY_TREE
@@
-610,7
+614,13
@@
bool directory_tree::compare_trees(const directory_tree &source,
if (!target_now // there was no node, so we're adding everything...
|| !target_now->_files.member_with_state(*files[i], how_compare) ) {
// ... or we need to add this file since it's missing.
if (!target_now // there was no node, so we're adding everything...
|| !target_now->_files.member_with_state(*files[i], how_compare) ) {
// ... or we need to add this file since it's missing.
-
+/*
+//hmmm: this one might be redundant. we shouldn't add it in the first place.
+ if (!files[i]->is_normal()) {
+ LOG(astring("skipping abnormal file: ") + *files[i]);
+ continue; // wasn't useful to do this one.
+ }
+*/
#ifdef DEBUG_DIRECTORY_TREE
LOG(astring("adding record: ") + files[i]->text_form());
#endif
#ifdef DEBUG_DIRECTORY_TREE
LOG(astring("adding record: ") + files[i]->text_form());
#endif
@@
-778,12
+788,16
@@
outcome directory_tree::add_path(const astring &new_item, bool just_size)
filename adding(new_item);
if (!adding.good()) {
LOG(astring("non-existent new item! ") + new_item);
filename adding(new_item);
if (!adding.good()) {
LOG(astring("non-existent new item! ") + new_item);
+ return common::NOT_FOUND; // not an existing path.
+ }
+ if (!adding.is_normal()) {
+ LOG(astring("abnormal new item: ") + new_item);
return common::BAD_INPUT; // not a good path.
}
int file_subtract = 0; // if it's a file, then we remove last component.
if (!adding.is_directory()) file_subtract = 1;
#ifdef DEBUG_DIRECTORY_TREE
return common::BAD_INPUT; // not a good path.
}
int file_subtract = 0; // if it's a file, then we remove last component.
if (!adding.is_directory()) file_subtract = 1;
#ifdef DEBUG_DIRECTORY_TREE
- if (file_subtract) LOG(astring("adding a file ") + new_item)
+ if (file_subtract) LOG(astring("adding a file ") + new_item)
;
else LOG(astring("adding a directory ") + new_item);
#endif
else LOG(astring("adding a directory ") + new_item);
#endif
diff --git
a/nucleus/library/filesystem/filename.cpp
b/nucleus/library/filesystem/filename.cpp
index 1ab0c0d496dabf4c1503e3414b9fc5ebb871bda6..2a97d3a44683112f17c371bef79be50d48693f5f 100644
(file)
--- a/
nucleus/library/filesystem/filename.cpp
+++ b/
nucleus/library/filesystem/filename.cpp
@@
-304,6
+304,18
@@
bool filename::is_executable() const
return !!(fill.st_mode & S_IEXEC);
}
return !!(fill.st_mode & S_IEXEC);
}
+bool filename::is_normal() const
+{
+ status_info fill;
+ if (!get_info(&fill))
+ return false;
+ bool weird = S_ISCHR(fill.st_mode)
+ || S_ISBLK(fill.st_mode)
+ || S_ISFIFO(fill.st_mode)
+ || S_ISSOCK(fill.st_mode);
+ return !weird;
+}
+
int filename::find_last_separator(const astring &look_at) const
{
int last_sep = -1;
int filename::find_last_separator(const astring &look_at) const
{
int last_sep = -1;
diff --git
a/nucleus/library/filesystem/filename.h
b/nucleus/library/filesystem/filename.h
index 1f2c7d3ba34bf40a302ade79e41a447911c73d3e..8e257358def959d93da0fcb8c4e2e2e8ff271448 100644
(file)
--- a/
nucleus/library/filesystem/filename.h
+++ b/
nucleus/library/filesystem/filename.h
@@
-141,6
+141,10
@@
public:
bool is_readable() const;
bool is_executable() const;
bool is_readable() const;
bool is_executable() const;
+ // is_normal makes sure that the file or directory is not a named pipe or other
+ // special type of file. symbolic links are considered normal.
+ bool is_normal() const;
+
enum write_modes {
ALLOW_NEITHER = 0x0,
ALLOW_READ = 0x1, ALLOW_WRITE = 0x2,
enum write_modes {
ALLOW_NEITHER = 0x0,
ALLOW_READ = 0x1, ALLOW_WRITE = 0x2,
diff --git
a/octopi/library/tentacles/file_transfer_tentacle.cpp
b/octopi/library/tentacles/file_transfer_tentacle.cpp
index fa082b990073f94a8feb26b341329929e41b0695..c4abe989fed0a5791c50322a996a05366f1e622a 100644
(file)
--- a/
octopi/library/tentacles/file_transfer_tentacle.cpp
+++ b/
octopi/library/tentacles/file_transfer_tentacle.cpp
@@
-46,7
+46,7
@@
const int FTT_CLEANING_INTERVAL = 30 * SECOND_ms;
const int TRANSFER_TIMEOUT = 10 * MINUTE_ms;
// if it hasn't been touched in this long, it's out of there.
const int TRANSFER_TIMEOUT = 10 * MINUTE_ms;
// if it hasn't been touched in this long, it's out of there.
-
//
#define DEBUG_FILE_TRANSFER_TENTACLE
+#define DEBUG_FILE_TRANSFER_TENTACLE
// uncomment for noisier version.
#undef LOG
// uncomment for noisier version.
#undef LOG
diff --git
a/octopi/library/tentacles/recursive_file_copy.cpp
b/octopi/library/tentacles/recursive_file_copy.cpp
index 8464ed4e073583f097ad2ced86e9921e735095a1..657bc80cd24744678d5d81180f61740680ccf64f 100644
(file)
--- a/
octopi/library/tentacles/recursive_file_copy.cpp
+++ b/
octopi/library/tentacles/recursive_file_copy.cpp
@@
-141,7
+141,7
@@
outcome recursive_file_copy::copy_hierarchy(int transfer_mode,
int iter = 0;
while (true) {
int iter = 0;
while (true) {
-
//
LOG(a_sprintf("ongoing chunk %d", ++iter));
+LOG(a_sprintf("ongoing chunk %d", ++iter));
// keep going until we find a broken reply.
file_transfer_infoton *ongoing = new file_transfer_infoton;
// keep going until we find a broken reply.
file_transfer_infoton *ongoing = new file_transfer_infoton;