Skip to content

Commit

Permalink
Skip .org files in archives - allows to keep backup copies of correct…
Browse files Browse the repository at this point in the history
…ed books inplace
  • Loading branch information
rupor-github committed Oct 9, 2016
1 parent d917c41 commit c203d32
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
project(InpxCreator)
# Project version number
set(PRJ_VERSION_MAJOR 7)
set(PRJ_VERSION_MINOR 1)
set(PRJ_VERSION_MINOR 2)
configure_file("${PROJECT_SOURCE_DIR}/cmake/version.h.in" "${PROJECT_BINARY_DIR}/version.h")
include_directories("${PROJECT_BINARY_DIR}")

Expand Down
20 changes: 20 additions & 0 deletions lib2inpx/lib2inpx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ bool is_fictionbook(const string& file)
return ((0 == _stricmp(ext.c_str(), "fb2")) && is_numeric(name));
}

bool is_backup(const string& file)
{
string name = file, ext;
size_t pos = name.rfind(".");

if (string::npos != pos) {
ext = name.substr(pos + 1);
}

return 0 == _stricmp(ext.c_str(), "org");
}

void clean_directory(const char* path)
{
_finddata_t fd;
Expand Down Expand Up @@ -880,6 +892,14 @@ void process_local_archives(const mysql_connection& mysql, const zip& zz, const
unzip uz((archives_path + *it).c_str());

for (unsigned int ni = 0; ni < uz.count(); ++ni) {

if (is_backup(uz.current())) {
if (ni < (uz.count() - 1)) {
uz.move_next();
}
continue;
}

string inp, book_id, ext, stmt;
bool fdummy = false;
bool fb2 = is_fictionbook(uz.current());
Expand Down

0 comments on commit c203d32

Please sign in to comment.