z_dropbox (zotonic_core v1.0.0-rc.17)

Simple drop folder handler, monitors a directory and signals new files.

Flow: 1. a user uploads/moves a file to the drop folder directory 2. Drop folder handler sees the file, moves it so a safe place, and notifies the file handler of it existance.

Summary

Functions

Convert process state when code is changed

Directory used by dropbox to scan for new files. Drop a files here to let the dropbox pick it up.

After a file is processed a module can move it to the handled directory.

Directory used by dropbox to contain files to be processed.

If a file could not be process it is moved to the unhandled directory.

Scan the drop folder, broadcast found files.

Handling all non call/cast messages

Initiates the server. Options are: dropbox_dir, processing_dir, unhandled_dir, interval, max_age and min_age

Perform a scan of the drop folder, periodically called by a timer and by mod_admin after a file has been uploaded to the dropbox.

Starts the drop folder server

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.

Functions

code_change(OldVsn, State, Extra)

-spec code_change(term(), term(), term()) -> {ok, term()}.

Convert process state when code is changed

dropbox_dir(Context)

Directory used by dropbox to scan for new files. Drop a files here to let the dropbox pick it up.

dropbox_handled_dir(Context)

After a file is processed a module can move it to the handled directory.

dropbox_processing_dir(Context)

Directory used by dropbox to contain files to be processed.

dropbox_unhandled_dir(Context)

If a file could not be process it is moved to the unhandled directory.

handle_call(Message, From, State)

Trap unknown calls

handle_cast(Message, State)

-spec handle_cast(term(), term()) ->
                     {noreply, term()} |
                     {noreply, term(), timeout() | hibernate} |
                     {stop, term(), term()}.

Scan the drop folder, broadcast found files.

handle_info(Info, State)

-spec handle_info(term(), term()) ->
                     {noreply, term()} |
                     {noreply, term(), timeout() | hibernate} |
                     {stop, term(), term()}.

Handling all non call/cast messages

init(Site)

-spec init(term()) -> {ok, term()} | {ok, term(), timeout() | hibernate} | ignore | {stop, term()}.

Initiates the server. Options are: dropbox_dir, processing_dir, unhandled_dir, interval, max_age and min_age

scan(Context)

-spec scan(Context) -> ok when Context :: z:context().

Perform a scan of the drop folder, periodically called by a timer and by mod_admin after a file has been uploaded to the dropbox.

start_link(Site)

-spec start_link(term()) -> {ok, pid()} | ignore | {error, term()}.

Starts the drop folder server

terminate(Reason, State)

-spec terminate(term(), term()) -> ok.

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.