<commit_before>// Copyright 2013 Joyent, Inc.  All rights reserved.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

var nfs = require('nfs');
var path = require('path');

var common = require('./common');



///-- API

function remove_lookup_dir(call, reply, next) {
    var log = call.log;

    log.debug('remove_lookup_dir(%s): entered', call._object.dir);
    call.fs.fhandle_to_path(call._object.dir, function (err, name) {
        if (err) {
            log.warn(err, 'remove_lookup_dir(%s): fhandle_to_path notfound',
                call._object.dir);
            reply.error(nfs.NFS3ERR_STALE);
            next(false);
        } else {
            call._dirname = name;
            call._filename = path.join(name, call._object.name);
            log.debug('remove_lookup_dir(%s): done -> %s', call._object.dir,
                name);
            next();
        }
    });
}


function remove_stat_dir(call, reply, next) {
    var log = call.log;

    log.debug('remove_stat_dir(%s): entered', call._filename);
    call.fs.stat(call._filename, function (err, stats) {
        if (err) {
            log.warn(err, 'remove_stat_dir(%s): failed', call._filename);
            reply.error(nfs.NFS3ERR_SERVERFAULT);
            next(false);
            return;
        }
        if (stats.isDirectory()) {
            log.warn(err, 'remove_stat_dir(%s): is a directory',
                call._filename);
            reply.error(nfs.NFS3ERR_NOTDIR);
            next(false);
            return;
        }

        log.debug('remove_stat_dir(%s): done', call._filename);
        next();
    });
}


function remove(call, reply, next) {
    var log = call.log;

    log.debug('remove(%s): entered', call._filename);
    call.fs.unlink(call._filename, function (err) {
        if (err) {
            log.warn(err, 'remove(%s): failed', call._filename);
            // XXX error
            reply.error(nfs.NFS3ERR_NOTDIR);
            next(false);
            return;
        }

        log.debug('remove(%s): done', call._filename);<commit_msg>MANTA-1844 cleanup remove<commit_after>// Copyright 2014 Joyent, Inc.  All rights reserved.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

var nfs = require('nfs');
var path = require('path');

var common = require('./common');



///-- API

function remove_lookup_dir(call, reply, next) {
    var log = call.log;

    log.debug('remove_lookup_dir(%s): entered', call._object.dir);
    call.fs.fhandle_to_path(call._object.dir, function (err, name) {
        if (err) {
            log.warn(err, 'remove_lookup_dir(%s): fhandle_to_path notfound',
                call._object.dir);
            reply.error(nfs.NFS3ERR_STALE);
            next(false);
        } else {
            call._dirname = name;
            call._filename = path.join(name, call._object.name);
            log.debug('remove_lookup_dir(%s): done -> %s', call._object.dir,
                name);
            next();
        }
    });
}


function remove_stat_dir(call, reply, next) {
    var log = call.log;

    log.debug('remove_stat_dir(%s): entered', call._filename);
    call.fs.stat(call._filename, function (err, stats) {
        if (err) {
            log.warn(err, 'remove_stat_dir(%s): failed', call._filename);
            reply.error(nfs.NFS3ERR_SERVERFAULT);
            next(false);
            return;
        }
        if (stats.isDirectory()) {
            log.warn(err, 'remove_stat_dir(%s): is a directory',
                call._filename);
            reply.error(nfs.NFS3ERR_NOTDIR);
            next(false);
            return;
        }

        log.debug('remove_stat_dir(%s): done', call._filename);
        next();
    });
}


function remove(call, reply, next) {
    var log = call.log;

    log.debug('remove(%s): entered', call._filename);
    call.fs.unlink(call._filename, function (err) {
        if (err) {
            log.warn(err, 'remove(%s): failed', call._filename);
            common.handle_error(err, call, reply, next);
            return;
        }

        log.debug('remove(%s): done', call._filename);
{'fraction_non_alphanumeric': 0.1461187214611872, 'fraction_numerical': 0.0061643835616438354, 'mean_word_length': 2.1248216833095577, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3552934', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1345, 'n_words': 305}