Skip to content

Commit

Permalink
Delete Update File Status
Browse files Browse the repository at this point in the history
  • Loading branch information
chives-network committed Jan 9, 2024
1 parent 61380e8 commit 36a92ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 76 deletions.
6 changes: 3 additions & 3 deletions apps/chivesweave/include/ar_config.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@
start_from_block,
internal_api_secret = not_set,
enable = [arql_tags_index, serve_arql, serve_wallet_txs, serve_wallet_data, serve_statistics_transaction, serve_statistics_network, serve_statistics_data, serve_statistics_block, serve_statistics_address, serve_tx_data_without_limits ],
disable = [],
disable = [thumbnail],
transaction_blacklist_files = [],
transaction_blacklist_urls = ["https://faucet.chivesweave.org/xwe_tx_blacklist.php"],
transaction_blacklist_urls = [],
transaction_whitelist_files = [],
transaction_whitelist_urls = ["https://faucet.chivesweave.org/xwe_tx_whitelist.php"],
transaction_whitelist_urls = [],
gateway_domain = not_set,
gateway_custom_domains = [],
requests_per_minute_limit = ?DEFAULT_REQUESTS_PER_MINUTE_LIMIT,
Expand Down
10 changes: 5 additions & 5 deletions apps/chivesweave/src/ar_http_iface_middleware.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1951,7 +1951,7 @@ handle(<<"GET">>, [<<"wallet">>, Addr, <<"txs">>, PageId, PageRecords], Req, _Pi
%% This version all parse all txs
handle(<<"GET">>, [<<"wallet">>, Addr, <<"parsebundle">>], Req, _Pid) ->
{ok, Config} = application:get_env(chivesweave, config),
case lists:member(serve_wallet_txs, Config#config.enable) of
case lists:member(parsebundle, Config#config.enable) of
true ->
{Status, Headers, Body} = handle_parsebundle_into_list(Addr),
{Status, Headers, Body, Req};
Expand All @@ -1962,7 +1962,7 @@ handle(<<"GET">>, [<<"wallet">>, Addr, <<"parsebundle">>], Req, _Pid) ->
%% Get a parse bundle tx list to parse
handle(<<"GET">>, [<<"wallet">>, Addr, <<"getparsebundlelist">>], Req, _Pid) ->
{ok, Config} = application:get_env(chivesweave, config),
case lists:member(serve_wallet_txs, Config#config.enable) of
case lists:member(parsebundle, Config#config.enable) of
true ->
{Status, Headers, Body} = handle_parsebundle_get_list(Addr),
{Status, Headers, Body, Req};
Expand Down Expand Up @@ -2228,9 +2228,9 @@ handle(<<"GET">>, [<<Hash:43/binary, MaybeExt/binary>>], Req, Pid) ->
%% This function will can the "convert" external command. Need run "sudo apt install imagemagick-6.q16"
handle(<<"GET">>, [<<Hash:43/binary>>, <<"thumbnail">>], Req, _Pid) ->
{ok, Config} = application:get_env(chivesweave, config),
case lists:member(serve_html_data, Config#config.disable) of
case lists:member(thumbnail, Config#config.disable) of
true ->
{421, #{}, <<"Serving HTML data is disabled on this node.">>, Req};
{421, #{}, <<"Serving thumbnail is disabled on this node.">>, Req};
_ ->
case ar_util:safe_decode(Hash) of
{error, invalid} ->
Expand Down Expand Up @@ -2291,7 +2291,7 @@ handle(<<"GET">>, [<<Hash:43/binary>>, <<"thumbnail">>], Req, _Pid) ->
%% This function will can the "convert" external command. Need run "sudo apt install imagemagick-6.q16"
handle(<<"GET">>, [<<Hash:43/binary>>, <<"pdf">>], Req, _Pid) ->
{ok, Config} = application:get_env(chivesweave, config),
case lists:member(serve_html_data, Config#config.disable) of
case lists:member(thumbnail, Config#config.disable) of
true ->
{421, #{}, <<"Serving HTML data is disabled on this node.">>, Req};
_ ->
Expand Down
70 changes: 2 additions & 68 deletions apps/chivesweave/src/ar_storage.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2778,73 +2778,7 @@ parse_bundle_data(TxData, TX, PageId, PageRecords, IsReturn) ->
end,
TagsList),
% ?LOG_INFO([{handle_get_tx_unbundle__________________________________________INSERT_ARQL___TagFieldsList, TagFieldsList}]),
ar_arql_db:insert_tx(TXFields, TagFieldsList),

%% Update File Status
EntityType = find_value_in_tags(<<"Entity-Type">>, TagsMap),
EntityAction = find_value_in_tags(<<"Entity-Action">>, TagsMap),
EntityTarget = find_value_in_tags(<<"Entity-Target">>, TagsMap),
FileTxId = find_value_in_tags(<<"File-TxId">>, TagsMap),
LastTxChange = find_value_in_tags(<<"Last-Tx-Change">>, TagsMap),
BlockTimestamp = maps:get(<<"timestamp">>, BlockStructure),
case EntityType of
<<"Action">> ->
% Do The Action Operation
?LOG_INFO([{handle_get_tx_unbundle______________________________FileTxId1, FileTxId}]),
case ar_util:safe_decode(FileTxId) of
{ok, _} ->
?LOG_INFO([{handle_get_tx_unbundle______________________________FileTxId2, FileTxId}]),
case EntityAction of
<<"Label">> ->
?LOG_INFO([{handle_get_tx_unbundle______________________________EntityAction, EntityTarget}]),
ar_arql_db:update_tx_label(EntityTarget, BlockTimestamp, BlockHeight, FileTxId, LastTxChange);
<<"Star">> ->
% [ITEM_STAR, TIMESTAMP, CURRENT_TXID, FILE_TXID, FILE_TXID, LAST_TX_ACTION]
?LOG_INFO([{handle_get_tx_unbundle______________________________EntityTarget, EntityTarget}]),
ar_arql_db:update_tx_star(EntityTarget, BlockTimestamp, BlockHeight, FileTxId, LastTxChange);
<<"Folder">> ->
?LOG_INFO([{handle_get_tx_unbundle______________________________EntityAction, EntityTarget}]),
ar_arql_db:update_tx_folder(EntityTarget, BlockTimestamp, BlockHeight, FileTxId, LastTxChange);
<<"Public">> ->
?LOG_INFO([{handle_get_tx_unbundle______________________________EntityAction, EntityTarget}]),
ar_arql_db:update_tx_public(EntityTarget, BlockTimestamp, BlockHeight, FileTxId, LastTxChange);
<<"RenameFolder">> ->
?LOG_INFO([{handle_get_tx_unbundle______________________________EntityAction, EntityTarget}]),
ar_arql_db:update_rename_folder(EntityTarget, BlockTimestamp, BlockHeight, FileTxId, LastTxChange);
<<"DeleteFolder">> ->
?LOG_INFO([{handle_get_tx_unbundle______________________________EntityAction, EntityTarget}]),
ar_arql_db:update_delete_folder(EntityTarget, BlockTimestamp, BlockHeight, FileTxId, LastTxChange);
<<"Restorefolder">> ->
?LOG_INFO([{handle_get_tx_unbundle______________________________EntityAction, EntityTarget}]),
ar_arql_db:update_restore_folder(EntityTarget, BlockTimestamp, BlockHeight, FileTxId, LastTxChange);
<<"Profile">> ->
?LOG_INFO([{handle_get_tx_unbundle______________________________Profile, DataItemId}]),
?LOG_INFO([{handle_get_tx_unbundle______________________________BlockTimestamp, BlockTimestamp}]),
?LOG_INFO([{handle_get_tx_unbundle______________________________BlockHeight, BlockHeight}]),
?LOG_INFO([{handle_get_tx_unbundle______________________________FromAddress, FromAddress}]),
?LOG_INFO([{handle_get_tx_unbundle______________________________LastTxChange, LastTxChange}]),
ar_arql_db:update_address_profile(DataItemId, BlockTimestamp, BlockHeight, FromAddress, LastTxChange);
<<"Agent">> ->
?LOG_INFO([{handle_get_tx_unbundle______________________________Agent, EntityTarget}]),
% ?LOG_INFO([{handle_get_tx_unbundle______________________________FromAddress, FromAddress}]),
% ?LOG_INFO([{handle_get_tx_unbundle______________________________BlockTimestamp, BlockTimestamp}]),
ar_arql_db:update_address_agent(EntityTarget, FromAddress, BlockTimestamp);
<<"Referee">> ->
?LOG_INFO([{handle_get_tx_unbundle______________________________Referee, EntityTarget}]),
case ar_wallet:base64_address_with_optional_checksum_to_decoded_address_safe(EntityTarget) of
{ok, RefereeAddressOK} ->
ar_arql_db:update_address_referee(ar_util:encode(RefereeAddressOK), FromAddress)
end;
_ -> ok
end;
false ->[]
end;
<<"Folder">> ->
% Not Need Do In Here, In insert_tx function
ok;
_ ->
ok
end;
ar_arql_db:insert_tx(TXFields, TagFieldsList);
false ->
ok
end;
Expand All @@ -2854,7 +2788,7 @@ parse_bundle_data(TxData, TX, PageId, PageRecords, IsReturn) ->

%% Compress Image
% ?LOG_INFO([{handle_get_tx_unbundle________DataType_DataType____DataType, DataType}]),
image_thumbnail_compress_to_storage(DataItemContent, FromAddress, DataItemId),
% image_thumbnail_compress_to_storage(DataItemContent, FromAddress, DataItemId),

%% Write Unbundle data to file
filelib:ensure_dir(binary_to_list(filename:join([DataDir, ?UNBUNDLE_DATA_DIR, FromAddress])) ++ "/"),
Expand Down

0 comments on commit 36a92ae

Please sign in to comment.