diff options
-rwxr-xr-x | pttbbs/daemon/postd/postd.py | 10 | ||||
-rw-r--r-- | pttbbs/daemon/postd/rebuild.c | 10 |
2 files changed, 11 insertions, 9 deletions
diff --git a/pttbbs/daemon/postd/postd.py b/pttbbs/daemon/postd/postd.py index 2d5deffc..4e9d1fe7 100755 --- a/pttbbs/daemon/postd/postd.py +++ b/pttbbs/daemon/postd/postd.py @@ -165,29 +165,31 @@ def handle_request(socket, _): content_len = SavePost(None, False, key, header, extra) fd.write(struct.pack(CONTENT_LEN_FORMAT, content_len)) elif req.operation == REQ_IMPORT: + num = 0 g_db.batch(True) while req.operation == REQ_IMPORT: + num += 1 header = DecodeFileHeader(fd.read(pttstruct.FILEHEADER_SIZE)) extra = read_and_unpack(fd, AddRecordFormatString, AddRecord) key = read_and_unpack(fd, PostKeyFormatString, PostKey) content_len = SavePost(None, True, key, header, extra) - fd.write(struct.pack(CONTENT_LEN_FORMAT, content_len)) - fd.flush() req = read_and_unpack(fd, RequestFormatString, Request) g_db.batch(False) + fd.write(struct.pack(CONTENT_LEN_FORMAT, num)) elif req.operation == REQ_IMPORT_REMOTE: + num = 0 g_db.batch(True) while req.operation == REQ_IMPORT_REMOTE: + num += 1 header = DecodeFileHeader(fd.read(pttstruct.FILEHEADER_SIZE)) extra = read_and_unpack(fd, AddRecordFormatString, AddRecord) key = read_and_unpack(fd, PostKeyFormatString, PostKey) content_len = read_and_unpack(fd, CONTENT_LEN_FORMAT)[0] content = fd.read(content_len) content_len = SavePost(content, True, key, header, extra) - fd.write(struct.pack(CONTENT_LEN_FORMAT, content_len)) - fd.flush() req = read_and_unpack(fd, RequestFormatString, Request) g_db.batch(False) + fd.write(struct.pack(CONTENT_LEN_FORMAT, num)) elif req.operation == REQ_GET_CONTENT: key = read_and_unpack(fd, PostKeyFormatString, PostKey) content = GetPostContent(key) diff --git a/pttbbs/daemon/postd/rebuild.c b/pttbbs/daemon/postd/rebuild.c index 919e9b35..6c710c5f 100644 --- a/pttbbs/daemon/postd/rebuild.c +++ b/pttbbs/daemon/postd/rebuild.c @@ -8,7 +8,6 @@ int PostAddRecord(int s, const char *board, const fileheader_t *fhdr, const char { int success = 1; PostAddRequest req = {0}; - uint32_t len = 0; char *userid; char xuid[IDLEN + 1]; @@ -70,11 +69,9 @@ int PostAddRecord(int s, const char *board, const fileheader_t *fhdr, const char success = 0; } free(content); + if (success) + printf(" (content: %d)", content_len); } - if (success && toread(s, &len, sizeof(len)) < 0) - success = 0; - if (success) - printf(" (content: %d)", len); return !success; } @@ -124,9 +121,12 @@ void rebuild_board(int bid GCC_UNUSED, boardheader_t *bp, int is_remote) // shutdown request { + int32_t num = 0; PostAddRequest req = {0}; req.cb = sizeof(req); towrite(s, &req, sizeof(req)); + toread(s, &num, sizeof(num)); + printf(" (total added %d entries)\n", num); close(s); } |