fix: [submit paste] remove item full path, use rel path

pull/350/head
Terrtia 2019-04-26 10:22:02 +02:00
parent 3e6fbc8f79
commit ff14fe6279
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
1 changed files with 9 additions and 4 deletions

View File

@ -36,15 +36,18 @@ def create_paste(uuid, paste_content, ltags, ltagsgalaxies, name):
abord_file_submission(uuid, "file error") abord_file_submission(uuid, "file error")
return 1 return 1
# use relative path
rel_item_path = save_path.replace(PASTES_FOLDER, '', 1)
# send paste to Global module # send paste to Global module
relay_message = "{0} {1}".format(save_path, gzip64encoded) relay_message = "{0} {1}".format(rel_item_path, gzip64encoded)
p.populate_set_out(relay_message, 'Mixer') p.populate_set_out(relay_message, 'Mixer')
# increase nb of paste by feeder name # increase nb of paste by feeder name
r_serv_log_submit.hincrby("mixer_cache:list_feeder", "submitted", 1) r_serv_log_submit.hincrby("mixer_cache:list_feeder", "submitted", 1)
# add tags # add tags
add_tags(ltags, ltagsgalaxies, full_path) add_tags(ltags, ltagsgalaxies, rel_item_path)
r_serv_log_submit.incr(uuid + ':nb_end') r_serv_log_submit.incr(uuid + ':nb_end')
r_serv_log_submit.incr(uuid + ':nb_sucess') r_serv_log_submit.incr(uuid + ':nb_sucess')
@ -52,8 +55,8 @@ def create_paste(uuid, paste_content, ltags, ltagsgalaxies, name):
if r_serv_log_submit.get(uuid + ':nb_end') == r_serv_log_submit.get(uuid + ':nb_total'): if r_serv_log_submit.get(uuid + ':nb_end') == r_serv_log_submit.get(uuid + ':nb_total'):
r_serv_log_submit.set(uuid + ':end', 1) r_serv_log_submit.set(uuid + ':end', 1)
print(' {} send to Global'.format(save_path)) print(' {} send to Global'.format(rel_item_path))
r_serv_log_submit.sadd(uuid + ':paste_submit_link', full_path) r_serv_log_submit.sadd(uuid + ':paste_submit_link', rel_item_path)
curr_date = datetime.date.today() curr_date = datetime.date.today()
serv_statistics.hincrby(curr_date.strftime("%Y%m%d"),'submit_paste', 1) serv_statistics.hincrby(curr_date.strftime("%Y%m%d"),'submit_paste', 1)
@ -206,6 +209,8 @@ if __name__ == "__main__":
config_section = 'submit_paste' config_section = 'submit_paste'
p = Process(config_section) p = Process(config_section)
PASTES_FOLDER = os.path.join(os.environ['AIL_HOME'], cfg.get("Directories", "pastes")) + '/'
while True: while True:
# paste submitted # paste submitted